linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] scsi: Only return started requests from scsi_host_find_tag()
@ 2020-06-22  6:30 Hannes Reinecke
  2020-07-25  2:50 ` Martin K. Petersen
  0 siblings, 1 reply; 2+ messages in thread
From: Hannes Reinecke @ 2020-06-22  6:30 UTC (permalink / raw)
  To: Martin K. Petersen
  Cc: Christoph Hellwig, James Bottomley, linux-scsi, Hannes Reinecke

scsi_host_find_tag() is used by the drivers to return a scsi
command based on the command tag. Typically it's used from the
interrupt handler to fetch the command associated with a value
returned from hardware. Some drivers like fnic or qla4xxx, however,
also use it also to traverse outstanding comands.
With the current implementation scsi_host_find_tag() will return
command even if they are not started (ie passed to the driver).
This will result in random errors with those drivers.
With this patch scsi_host_find_tag() will only return 'started'
commands (ie commands which have been passed to the drivers)
thus avoiding the above issue.
The other usecases will be unaffected as the interrupt handler
naturally will only ever return 'started' requests.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 include/scsi/scsi_tcq.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/scsi/scsi_tcq.h b/include/scsi/scsi_tcq.h
index 6053d46e794e..ea7848e74d25 100644
--- a/include/scsi/scsi_tcq.h
+++ b/include/scsi/scsi_tcq.h
@@ -34,7 +34,7 @@ static inline struct scsi_cmnd *scsi_host_find_tag(struct Scsi_Host *shost,
 					blk_mq_unique_tag_to_tag(tag));
 	}
 
-	if (!req)
+	if (!req || !blk_mq_request_started(req))
 		return NULL;
 	return blk_mq_rq_to_pdu(req);
 }
-- 
2.16.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] scsi: Only return started requests from scsi_host_find_tag()
  2020-06-22  6:30 [PATCH] scsi: Only return started requests from scsi_host_find_tag() Hannes Reinecke
@ 2020-07-25  2:50 ` Martin K. Petersen
  0 siblings, 0 replies; 2+ messages in thread
From: Martin K. Petersen @ 2020-07-25  2:50 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Martin K . Petersen, Christoph Hellwig, James Bottomley, linux-scsi

On Mon, 22 Jun 2020 08:30:22 +0200, Hannes Reinecke wrote:

> scsi_host_find_tag() is used by the drivers to return a scsi
> command based on the command tag. Typically it's used from the
> interrupt handler to fetch the command associated with a value
> returned from hardware. Some drivers like fnic or qla4xxx, however,
> also use it also to traverse outstanding comands.
> With the current implementation scsi_host_find_tag() will return
> command even if they are not started (ie passed to the driver).
> This will result in random errors with those drivers.
> With this patch scsi_host_find_tag() will only return 'started'
> commands (ie commands which have been passed to the drivers)
> thus avoiding the above issue.
> The other usecases will be unaffected as the interrupt handler
> naturally will only ever return 'started' requests.

Applied to 5.9/scsi-queue, thanks!

[1/1] scsi: core: Only return started requests from scsi_host_find_tag()
      https://git.kernel.org/mkp/scsi/c/e73a5e8e8003

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-07-25  2:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-22  6:30 [PATCH] scsi: Only return started requests from scsi_host_find_tag() Hannes Reinecke
2020-07-25  2:50 ` Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).