Re: [PATCH 3/7] scsi: Use scsi_target as argument for eh_target_reset_handler()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




      /**
      *      eh_device_reset_handler - issue SCSI device reset
      *      @scp: identifies SCSI device to be reset
diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
index 86f16f3ea478..61a060dc7a17 100644
--- a/drivers/message/fusion/mptsas.c
+++ b/drivers/message/fusion/mptsas.c
@@ -1997,7 +1997,15 @@ static enum scsi_timeout_action mptsas_eh_timed_out(struct scsi_cmnd *sc)
  }
-static const struct scsi_host_template mptsas_driver_template = {
+static int mptsas_eh_target_reset(struct scsi_target *starget)
+{
+	struct sas_rphy *rphy = dev_to_rphy(starget->dev.parent);
+	MPT_ADAPTER *ioc = rphy_to_ioc(rphy);
+
+	return mptscsih_target_reset(ioc->sh, starget);
+}
+
+static struct scsi_host_template mptsas_driver_template = {

was dropping the const intentional?

  	.module				= THIS_MODULE,
  	.proc_name			= "mptsas",
  	.show_info			= mptscsih_show_info,
@@ -2012,7 +2020,7 @@ static const struct scsi_host_template mptsas_driver_template = {
  	.change_queue_depth 		= mptscsih_change_queue_depth,
  	.eh_timed_out			= mptsas_eh_timed_out,
  	.eh_abort_handler		= mptscsih_abort,
-	.eh_device_reset_handler	= mptscsih_dev_reset,
+	.eh_target_reset_handler	= mptsas_eh_target_reset,
  	.eh_host_reset_handler		= mptscsih_host_reset,
  	.bios_param			= mptscsih_bios_param,
  	.can_queue			= MPT_SAS_CAN_QUEUE,
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
index 591b2858f823..b31d74ea9cc8 100644
--- a/drivers/message/fusion/mptscsih.c
+++ b/drivers/message/fusion/mptscsih.c
@@ -1853,48 +1853,43 @@ mptscsih_dev_reset(struct scsi_cmnd * SCpnt)
   *	Returns SUCCESS or FAILED.
   **/
  int
-mptscsih_target_reset(struct scsi_cmnd * SCpnt)
+mptscsih_target_reset(struct Scsi_Host *shost, struct scsi_target * starget)
  {
  	MPT_SCSI_HOST	*hd;
  	int		 retval;
-	VirtDevice	 *vdevice;
+	VirtTarget	 *vtarget;
  	MPT_ADAPTER	*ioc;
/* If we can't locate our host adapter structure, return FAILED status.
  	 */
-	if ((hd = shost_priv(SCpnt->device->host)) == NULL){
-		printk(KERN_ERR MYNAM ": target reset: "
-		   "Can't locate host! (sc=%p)\n", SCpnt);
+	if ((hd = shost_priv(shost)) == NULL){

Is shost_priv(shost) == NULL even possible?

Doesn't shost_priv() just return the address to the driver shost priv data, which is at a fixed offset to shost pointer

...

  }
-static const struct scsi_host_template mptspi_driver_template = {
+static int mptspi_eh_target_reset(struct scsi_target *starget)
+{
+	struct Scsi_Host *shost = dev_to_shost(&starget->dev);
+	return mptscsih_target_reset(shost, starget);
+}
+
+static struct scsi_host_template mptspi_driver_template = {
  	.module				= THIS_MODULE,
  	.proc_name			= "mptspi",
  	.show_info			= mptscsih_show_info,
@@ -834,7 +840,7 @@ static const struct scsi_host_template mptspi_driver_template = {
  	.slave_destroy			= mptspi_slave_destroy,
  	.change_queue_depth 		= mptscsih_change_queue_depth,
  	.eh_abort_handler		= mptscsih_abort,
-	.eh_device_reset_handler	= mptscsih_dev_reset,
+	.eh_target_reset_handler	= mptspi_eh_target_reset,
  	.eh_bus_reset_handler		= mptscsih_bus_reset,
  	.eh_host_reset_handler		= mptscsih_host_reset,
  	.bios_param			= mptscsih_bios_param,
diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c
index 60ef1e2ab3cd..6bd07f704391 100644
--- a/drivers/s390/scsi/zfcp_scsi.c
+++ b/drivers/s390/scsi/zfcp_scsi.c
@@ -340,9 +340,12 @@ static int zfcp_scsi_eh_device_reset_handler(struct scsi_cmnd *scpnt)
  	return zfcp_scsi_task_mgmt_function(sdev, FCP_TMF_LUN_RESET);
  }

...

-int sas_eh_target_reset_handler(struct scsi_cmnd *cmd)
+int sas_eh_target_reset_handler(struct scsi_target *starget)
  {
  	int res;
-	struct Scsi_Host *host = cmd->device->host;
-	struct domain_device *dev = cmd_to_domain_dev(cmd);
+	struct domain_device *dev = starget_to_domain_dev(starget);
+	struct sas_rphy *rphy = dev->rphy;
+	struct Scsi_Host *host = dev_to_shost(rphy->dev.parent);
  	struct sas_internal *i = to_sas_internal(host->transportt);
if (current != host->ehandler)
@@ -515,7 +516,7 @@ static int try_to_reset_cmd_device(struct scsi_cmnd *cmd)
try_target_reset:
  	if (shost->hostt->eh_target_reset_handler)
-		return shost->hostt->eh_target_reset_handler(cmd);
+		return shost->hostt->eh_target_reset_handler(scsi_target(cmd->device));

this line looks too long

return FAILED;
  }

...

diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index 8a83f3fc2b86..0ad6be041298 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -4801,21 +4801,25 @@ int megasas_task_abort_fusion(struct scsi_cmnd *scmd)
/*
   * megasas_reset_target_fusion : target reset function for fusion adapters
- * scmd: SCSI command pointer
+ * shost: SCSI host pointer
+ * starget: SCSI target pointer
   *
   * Returns SUCCESS if all commands associated with target aborted else FAILED
   */
-int megasas_reset_target_fusion(struct scsi_cmnd *scmd)
+int megasas_reset_target_fusion(struct Scsi_Host *shost,
+				struct scsi_target *starget)
  {
struct megasas_instance *instance;
+	struct scsi_device *sdev;
  	int ret = FAILED;
-	u16 devhandle;
-	struct MR_PRIV_DEVICE *mr_device_priv_data;
-	mr_device_priv_data = scmd->device->hostdata;
+	u16 devhandle = USHRT_MAX;
+	struct MR_PRIV_DEVICE *mr_device_priv_data = NULL;
- instance = (struct megasas_instance *)scmd->device->host->hostdata;
+	instance = (struct megasas_instance *)shost->hostdata;
+	starget_printk(KERN_INFO, starget,
+		    "target reset called\n");
if (atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL) {
  		dev_err(&instance->pdev->dev, "Controller is not OPERATIONAL,"
@@ -4824,10 +4828,21 @@ int megasas_reset_target_fusion(struct scsi_cmnd *scmd)
  		return ret;
  	}
+ shost_for_each_device(sdev, shost) {
+		if (!sdev->hostdata)
+			continue;
+		if (sdev->sdev_target != starget)
+			continue;
+		mr_device_priv_data = sdev->hostdata;
+		if (mr_device_priv_data->is_tm_capable) {
+			devhandle = megasas_get_tm_devhandle(sdev);
+			break;
+		}
+	}

Do you require scsi_device_put(sdev)?

+
  	if (!mr_device_priv_data) {
-		sdev_printk(KERN_INFO, scmd->device,
-			    "device been deleted! scmd: (0x%p)\n", scmd);
-		scmd->result = DID_NO_CONNECT << 16;
+		starget_printk(KERN_INFO, starget,
+			    "all devices have been deleted\n");
  		ret = SUCCESS;
  		goto out;

...

- stgt_priv_data = sdev_priv_data->tgt_priv_data;
+	stgt_priv_data = (struct mpi3mr_stgt_priv_data *)
+		starget->hostdata;

starget->hostdata is a void *, so no need for casting
...

-static int pmcraid_eh_target_reset_handler(struct scsi_cmnd *scmd)
+static int pmcraid_eh_target_reset_handler(struct scsi_target *starget)
  {
-	struct Scsi_Host *shost = scmd->device->host;
+	struct Scsi_Host *shost = dev_to_shost(&starget->dev);
  	struct scsi_device *scsi_dev = NULL, *tmp;
shost_for_each_device(tmp, shost) {
-		if ((tmp->channel == scmd->device->channel) &&
-		    (tmp->id == scmd->device->id)) {
+		if ((tmp->channel == starget->channel) &&
+		    (tmp->id == starget->id)) {
  			scsi_dev = tmp;
  			break;
  		}
diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
index 413a5a0da433..f6876307c304 100644
--- a/drivers/scsi/qedf/qedf_main.c
+++ b/drivers/scsi/qedf/qedf_main.c
@@ -856,9 +856,8 @@ static int qedf_eh_abort(struct scsi_cmnd *sc_cmd)
  	return rc;
  }
-static int qedf_eh_target_reset(struct scsi_cmnd *sc_cmd)
+static int qedf_eh_target_reset(struct scsi_target *starget)
  {
-	struct scsi_target *starget = scsi_target(sc_cmd->device);
  	struct fc_rport *rport = starget_to_rport(starget);
QEDF_ERR(NULL, "TARGET RESET Issued...");
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index a9d9d0a9abd7..53bb73e07c3a 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -1514,10 +1514,9 @@ qla2xxx_eh_device_reset(struct scsi_cmnd *cmd)
  }
static int
-qla2xxx_eh_target_reset(struct scsi_cmnd *cmd)
+qla2xxx_eh_target_reset(struct scsi_target *starget)
  {
-	struct scsi_device *sdev = cmd->device;
-	struct fc_rport *rport = starget_to_rport(scsi_target(sdev));
+	struct fc_rport *rport = starget_to_rport(starget);
  	scsi_qla_host_t *vha = shost_priv(rport_to_shost(rport));
  	struct qla_hw_data *ha = vha->hw;
  	fc_port_t *fcport = *(fc_port_t **)rport->dd_data;
@@ -1542,40 +1541,39 @@ qla2xxx_eh_target_reset(struct scsi_cmnd *cmd)
  		return FAILED;
ql_log(ql_log_info, vha, 0x8009,
-	    "TARGET RESET ISSUED nexus=%ld:%d cmd=%p.\n", vha->host_no,
-	    sdev->id, cmd);
+	    "TARGET RESET ISSUED nexus=%ld:%d.\n", vha->host_no,
+	    starget->id);
err = 0;
  	if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) {
  		ql_log(ql_log_warn, vha, 0x800a,
-		    "Wait for hba online failed for cmd=%p.\n", cmd);
+		    "Wait for hba online failed.\n");

sidenote: maybe the maintainer for this driver would like a different log message, but they are not even cc'ed

...





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux