]> git.infradead.org Git - users/hch/misc.git/commitdiff
scsi: ibmvfc: Open-code reset loop for target reset
authorHannes Reinecke <hare@suse.de>
Mon, 2 Oct 2023 15:43:20 +0000 (17:43 +0200)
committerMartin K. Petersen <martin.petersen@oracle.com>
Fri, 13 Oct 2023 18:23:14 +0000 (14:23 -0400)
For target reset we need a device to send the target reset to, so open-code
the loop in target reset to send the target reset TMF to the correct
device.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Link: https://lore.kernel.org/r/20231002154328.43718-11-hare@suse.de
Cc: Tyrel Datwyler <tyreld@linux.ibm.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/ibmvscsi/ibmvfc.c

index ce9eb00e2ca04d6b1a500a39df6bcee19fd71e0f..42dc5b7df5d5cc6f35ec323b2edeb8cc25f259cc 100644 (file)
@@ -2930,18 +2930,6 @@ static void ibmvfc_dev_cancel_all_noreset(struct scsi_device *sdev, void *data)
        *rc |= ibmvfc_cancel_all(sdev, IBMVFC_TMF_SUPPRESS_ABTS);
 }
 
-/**
- * ibmvfc_dev_cancel_all_reset - Device iterated cancel all function
- * @sdev:      scsi device struct
- * @data:      return code
- *
- **/
-static void ibmvfc_dev_cancel_all_reset(struct scsi_device *sdev, void *data)
-{
-       unsigned long *rc = data;
-       *rc |= ibmvfc_cancel_all(sdev, IBMVFC_TMF_TGT_RESET);
-}
-
 /**
  * ibmvfc_eh_target_reset_handler - Reset the target
  * @cmd:       scsi command struct
@@ -2951,22 +2939,38 @@ static void ibmvfc_dev_cancel_all_reset(struct scsi_device *sdev, void *data)
  **/
 static int ibmvfc_eh_target_reset_handler(struct scsi_cmnd *cmd)
 {
-       struct scsi_device *sdev = cmd->device;
-       struct ibmvfc_host *vhost = shost_priv(sdev->host);
-       struct scsi_target *starget = scsi_target(sdev);
+       struct scsi_target *starget = scsi_target(cmd->device);
+       struct fc_rport *rport = starget_to_rport(starget);
+       struct Scsi_Host *shost = rport_to_shost(rport);
+       struct ibmvfc_host *vhost = shost_priv(shost);
        int block_rc;
        int reset_rc = 0;
        int rc = FAILED;
        unsigned long cancel_rc = 0;
+       bool tgt_reset = false;
 
        ENTER;
-       block_rc = fc_block_scsi_eh(cmd);
+       block_rc = fc_block_rport(rport);
        ibmvfc_wait_while_resetting(vhost);
        if (block_rc != FAST_IO_FAIL) {
-               starget_for_each_device(starget, &cancel_rc, ibmvfc_dev_cancel_all_reset);
-               reset_rc = ibmvfc_reset_device(sdev, IBMVFC_TARGET_RESET, "target");
+               struct scsi_device *sdev;
+
+               shost_for_each_device(sdev, shost) {
+                       if ((sdev->channel != starget->channel) ||
+                           (sdev->id != starget->id))
+                               continue;
+
+                       cancel_rc |= ibmvfc_cancel_all(sdev,
+                                                      IBMVFC_TMF_TGT_RESET);
+                       if (!tgt_reset) {
+                               reset_rc = ibmvfc_reset_device(sdev,
+                                       IBMVFC_TARGET_RESET, "target");
+                               tgt_reset = true;
+                       }
+               }
        } else
-               starget_for_each_device(starget, &cancel_rc, ibmvfc_dev_cancel_all_noreset);
+               starget_for_each_device(starget, &cancel_rc,
+                                       ibmvfc_dev_cancel_all_noreset);
 
        if (!cancel_rc && !reset_rc)
                rc = ibmvfc_wait_for_ops(vhost, starget, ibmvfc_match_target);