Patchwork [#upstream-fixes] libata: fix locking around blk_abort_request()

login
register
mail settings
Submitter Tejun Heo
Date April 14, 2010, 11:57 p.m.
Message ID <4BC65671.6000309@kernel.org>
Download mbox | patch
Permalink /patch/50204/
State Not Applicable
Delegated to: David Miller
Headers show

Comments

Tejun Heo - April 14, 2010, 11:57 p.m.
blk_abort_request() expectes queue lock to be held by the caller.
Grab it before calling the function.

Lack of this synchronization led to infinite loop on corrupt
q->timeout_list.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: stable@kernel.org
---
 drivers/ata/libata-eh.c |    4 ++++
 1 file changed, 4 insertions(+)

--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jeff Garzik - April 23, 2010, 1:52 a.m.
On 04/14/2010 07:57 PM, Tejun Heo wrote:
> blk_abort_request() expectes queue lock to be held by the caller.
> Grab it before calling the function.
>
> Lack of this synchronization led to infinite loop on corrupt
> q->timeout_list.
>
> Signed-off-by: Tejun Heo<tj@kernel.org>
> Cc: Jens Axboe<axboe@kernel.dk>
> Cc: stable@kernel.org
> ---
>   drivers/ata/libata-eh.c |    4 ++++
>   1 file changed, 4 insertions(+)

applied


--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index 9f6cfac..9e18cc9 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -879,6 +879,8 @@  static void ata_eh_set_pending(struct ata_port *ap, int fastdrain)
 void ata_qc_schedule_eh(struct ata_queued_cmd *qc)
 {
 	struct ata_port *ap = qc->ap;
+	struct request_queue *q = qc->scsicmd->device->request_queue;
+	unsigned long flags;

 	WARN_ON(!ap->ops->error_handler);

@@ -890,7 +892,9 @@  void ata_qc_schedule_eh(struct ata_queued_cmd *qc)
 	 * Note that ATA_QCFLAG_FAILED is unconditionally set after
 	 * this function completes.
 	 */
+	spin_lock_irqsave(q->queue_lock, flags);
 	blk_abort_request(qc->scsicmd->request);
+	spin_unlock_irqrestore(q->queue_lock, flags);
 }

 /**