Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: core: Only return started requests from scsi_host_find_tag()

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/20200622063022.67891-1-hare@suse.de
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Hannes Reinecke and committed by
Martin K. Petersen
e73a5e8e e2289db1

+1 -1
+1 -1
include/scsi/scsi_tcq.h
··· 34 34 blk_mq_unique_tag_to_tag(tag)); 35 35 } 36 36 37 - if (!req) 37 + if (!req || !blk_mq_request_started(req)) 38 38 return NULL; 39 39 return blk_mq_rq_to_pdu(req); 40 40 }