diff mbox series

[05/11] pmcraid: select first available device for target reset

Message ID 20220502215416.5351-6-hare@suse.de (mailing list archive)
State Deferred
Headers show
Series scsi: EH rework prep patches, part 2 | expand

Commit Message

Hannes Reinecke May 2, 2022, 9:54 p.m. UTC
As we're moving away from using a scsi command as argument for
eh_XX callbacks we should be selecting the first available device
for sending a target reset to.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/scsi/pmcraid.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

Comments

Christoph Hellwig May 3, 2022, 2:26 p.m. UTC | #1
Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
Bart Van Assche May 3, 2022, 4:24 p.m. UTC | #2
On 5/2/22 14:54, Hannes Reinecke wrote:
> As we're moving away from using a scsi command as argument for
> eh_XX callbacks we should be selecting the first available device
                   ^^^^^^^^^
> for sending a target reset to.
  Please explain in the commit message why selecting the first available 
device is the right approach.

Thanks,

Bart.
Hannes Reinecke May 3, 2022, 6:36 p.m. UTC | #3
On 5/3/22 09:24, Bart Van Assche wrote:
> On 5/2/22 14:54, Hannes Reinecke wrote:
>> As we're moving away from using a scsi command as argument for
>> eh_XX callbacks we should be selecting the first available device
>                    ^^^^^^^^^
>> for sending a target reset to.
>   Please explain in the commit message why selecting the first available 
> device is the right approach.
> 
That's due to the firmware interface of the pmcraid HBA.
All commands require a LUN number to be specified, so we need to select 
the first available drive on the bus to get a valid LUN.

It _might_ be that LUN 0 _could_ be sufficient here, but that would be 
change in behaviour and hard to validate. So this patch mimics the 
original behaviour to always fill in a valid LUN.

Cheers,

Hannes
diff mbox series

Patch

diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
index d508e81a03db..62b9de87ff05 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);
 }