diff mbox series

[5/9] scsi: Do not wait for a request in scsi_eh_lock_door()

Message ID 20200906012219.17893-6-bvanassche@acm.org (mailing list archive)
State New, archived
Headers show
Series Rework runtime suspend and SCSI domain validation | expand

Commit Message

Bart Van Assche Sept. 6, 2020, 1:22 a.m. UTC
It is not guaranteed that a request is available when scsi_eh_lock_door()
is called. Hence pass the BLK_MQ_REQ_NOWAIT flag to blk_get_request().
This patch has a second purpose, namely preventing that
scsi_eh_lock_door() deadlocks if sdev->request_queue is frozen and if a
SCSI command is submitted to a SCSI device through a second request queue
that has not been frozen.

Cc: Martin K. Petersen <martin.petersen@oracle.com>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Can Guo <cang@codeaurora.org>
Cc: Stanley Chu <stanley.chu@mediatek.com>
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/scsi_error.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Alan Stern Sept. 6, 2020, 4:03 p.m. UTC | #1
On Sat, Sep 05, 2020 at 06:22:15PM -0700, Bart Van Assche wrote:
> It is not guaranteed that a request is available when scsi_eh_lock_door()
> is called. Hence pass the BLK_MQ_REQ_NOWAIT flag to blk_get_request().
> This patch has a second purpose, namely preventing that
> scsi_eh_lock_door() deadlocks if sdev->request_queue is frozen and if a
> SCSI command is submitted to a SCSI device through a second request queue
> that has not been frozen.

I think it would help readers understand the reason for doing this if 
you mentioned that scsi_eh_lock_door() is the only place in the SCSI 
error handler that calls blk_get_request().

Also mention that an upcoming patch in this series requires the error 
handler to work okay even when the device's request queue is frozen.  
(That's what the second sentence of your description is getting at, but 
the connection is not clear.)

Alan Stern
diff mbox series

Patch

diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index b197291c631a..f7604d930e3c 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -1979,7 +1979,8 @@  static void scsi_eh_lock_door(struct scsi_device *sdev)
 	struct request *req;
 	struct scsi_request *rq;
 
-	req = blk_get_request(sdev->request_queue, REQ_OP_SCSI_IN, 0);
+	req = blk_get_request(sdev->request_queue, REQ_OP_SCSI_IN,
+			      BLK_MQ_REQ_NOWAIT);
 	if (IS_ERR(req))
 		return;
 	rq = scsi_req(req);