Skip to content

Commit

Permalink
scsi: core: Only return started requests from scsi_host_find_tag()
Browse files Browse the repository at this point in the history
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
commands.  With the current implementation scsi_host_find_tag() will return
commands even if they are not started (i.e. 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 (i.e. commands
which have been passed to the drivers) thus avoiding the above issue.  The
other use cases will be unaffected as the interrupt handler naturally will
only ever return 'started' requests.

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Hannes Reinecke <[email protected]>
Signed-off-by: Martin K. Petersen <[email protected]>
  • Loading branch information
hreinecke authored and martinkpetersen committed Jul 25, 2020
1 parent e2289db commit e73a5e8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion include/scsi/scsi_tcq.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit e73a5e8

Please sign in to comment.