Message ID | 20231002154328.43718-18-hare@suse.de |
---|---|
State | New |
Headers | show |
Series | scsi: EH rework prep patches, part 1 | expand |
On 02/10/2023 16:43, Hannes Reinecke wrote: > static int pmcraid_eh_target_reset_handler(struct scsi_cmnd *scmd) > { > - scmd_printk(KERN_INFO, scmd, > + struct Scsi_Host *shost = scmd->device->host; > + struct scsi_device *scsi_dev = NULL, *tmp; > + > + shost_for_each_device(tmp, shost) { > + if ((tmp->channel == scmd->device->channel) && > + (tmp->id == scmd->device->id)) { > + scsi_dev = tmp; > + break; If you break out of the loop, you must call scsi_device_put(sdev) - is that missing? > + } > + } > + if (!scsi_dev) > + return FAILED; > + sdev_printk(KERN_INFO, scsi_dev, > "Doing target reset due to an I/O command timeout.\n"); > - return pmcraid_reset_device(scmd->device,
On 10/5/23 14:26, John Garry wrote: > On 02/10/2023 16:43, Hannes Reinecke wrote: >> static int pmcraid_eh_target_reset_handler(struct scsi_cmnd *scmd) >> { >> - scmd_printk(KERN_INFO, scmd, >> + struct Scsi_Host *shost = scmd->device->host; >> + struct scsi_device *scsi_dev = NULL, *tmp; >> + >> + shost_for_each_device(tmp, shost) { >> + if ((tmp->channel == scmd->device->channel) && >> + (tmp->id == scmd->device->id)) { >> + scsi_dev = tmp; >> + break; > > If you break out of the loop, you must call scsi_device_put(sdev) - is > that missing? > No, you are correct. Will be fixing it up. Cheers, Hannes
diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c index d7a331255e71..a831b34c08a4 100644 --- a/drivers/scsi/pmcraid.c +++ b/drivers/scsi/pmcraid.c @@ -3064,9 +3064,21 @@ static int pmcraid_eh_bus_reset_handler(struct scsi_cmnd *scmd) static int pmcraid_eh_target_reset_handler(struct scsi_cmnd *scmd) { - scmd_printk(KERN_INFO, scmd, + struct Scsi_Host *shost = scmd->device->host; + struct scsi_device *scsi_dev = NULL, *tmp; + + shost_for_each_device(tmp, shost) { + if ((tmp->channel == scmd->device->channel) && + (tmp->id == scmd->device->id)) { + scsi_dev = tmp; + break; + } + } + if (!scsi_dev) + return FAILED; + sdev_printk(KERN_INFO, scsi_dev, "Doing target reset due to an I/O command timeout.\n"); - return pmcraid_reset_device(scmd->device, + return pmcraid_reset_device(scsi_dev, PMCRAID_INTERNAL_TIMEOUT, RESET_DEVICE_TARGET); }