All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: Christoph Hellwig <hch@lst.de>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>,
	James Bottomley <james.bottomley@hansenpartnership.com>,
	linux-scsi@vger.kernel.org, Hannes Reinecke <hare@suse.de>,
	Hannes Reinecke <hare@suse.com>
Subject: [PATCH 35/47] fnic: use dedicated device reset command
Date: Wed, 28 Jun 2017 10:33:01 +0200	[thread overview]
Message-ID: <1498638793-44672-36-git-send-email-hare@suse.de> (raw)
In-Reply-To: <1498638793-44672-1-git-send-email-hare@suse.de>

Use a dedicated command to send a device reset instead of relying
on using the command which triggered the device failure.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/scsi/fnic/fnic_main.c |  2 ++
 drivers/scsi/fnic/fnic_scsi.c | 78 +++++++++++++------------------------------
 2 files changed, 26 insertions(+), 54 deletions(-)

diff --git a/drivers/scsi/fnic/fnic_main.c b/drivers/scsi/fnic/fnic_main.c
index aacadbf..22fd37c 100644
--- a/drivers/scsi/fnic/fnic_main.c
+++ b/drivers/scsi/fnic/fnic_main.c
@@ -706,6 +706,8 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 					fnic->config.io_throttle_count));
 	}
 	fnic->fnic_max_tag_id = host->can_queue;
+	/* Reserve the last tag for device reset */
+	host->can_queue--;
 
 	host->max_lun = fnic->config.luns_per_tgt;
 	host->max_id = FNIC_MAX_FCP_TARGET;
diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c
index 731ec87..acf7d1d 100644
--- a/drivers/scsi/fnic/fnic_scsi.c
+++ b/drivers/scsi/fnic/fnic_scsi.c
@@ -2106,9 +2106,7 @@ static inline int fnic_queue_dr_io_req(struct fnic *fnic,
  * successfully aborted, 1 otherwise
  */
 static int fnic_clean_pending_aborts(struct fnic *fnic,
-				     struct scsi_cmnd *lr_sc,
-					 bool new_sc)
-
+				     struct scsi_cmnd *lr_sc)
 {
 	int tag, abt_tag;
 	struct fnic_io_req *io_req;
@@ -2129,7 +2127,7 @@ static int fnic_clean_pending_aborts(struct fnic *fnic,
 		 * ignore this lun reset cmd if issued using new SC
 		 * or cmds that do not belong to this lun
 		 */
-		if (!sc || ((sc == lr_sc) && new_sc) || sc->device != lun_dev) {
+		if (!sc || sc == lr_sc || sc->device != lun_dev) {
 			spin_unlock_irqrestore(io_lock, flags);
 			continue;
 		}
@@ -2334,6 +2332,7 @@ static int fnic_clean_pending_aborts(struct fnic *fnic,
  */
 int fnic_device_reset(struct scsi_cmnd *sc)
 {
+	struct scsi_device *sdev = sc->device;
 	struct fc_lport *lp;
 	struct fnic *fnic;
 	struct fnic_io_req *io_req = NULL;
@@ -2348,18 +2347,16 @@ int fnic_device_reset(struct scsi_cmnd *sc)
 	struct reset_stats *reset_stats;
 	int tag = 0;
 	DECLARE_COMPLETION_ONSTACK(tm_done);
-	int tag_gen_flag = 0;   /*to track tags allocated by fnic driver*/
-	bool new_sc = 0;
 
 	/* Wait for rport to unblock */
-	rport = starget_to_rport(scsi_target(sc->device));
+	rport = starget_to_rport(scsi_target(sdev));
 	ret = fc_block_scsi_eh(rport);
 	if (ret)
 		return ret;
 
 	ret = FAILED;
 	/* Get local-port, check ready and link up */
-	lp = shost_priv(sc->device->host);
+	lp = shost_priv(sdev->host);
 
 	fnic = lport_priv(lp);
 	fnic_stats = &fnic->fnic_stats;
@@ -2368,8 +2365,8 @@ int fnic_device_reset(struct scsi_cmnd *sc)
 	atomic64_inc(&reset_stats->device_resets);
 
 	FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
-		      "Device reset called FCID 0x%x, LUN 0x%llx sc 0x%p\n",
-		      rport->port_id, sc->device->lun, sc);
+		      "Device reset called FCID 0x%x, LUN 0x%llx\n",
+		      rport->port_id, sdev->lun);
 
 	if (lp->state != LPORT_ST_READY || !(lp->link_up))
 		goto fnic_device_reset_end;
@@ -2379,51 +2376,28 @@ int fnic_device_reset(struct scsi_cmnd *sc)
 		atomic64_inc(&fnic_stats->misc_stats.rport_not_ready);
 		goto fnic_device_reset_end;
 	}
-
-	CMD_FLAGS(sc) = FNIC_DEVICE_RESET;
-	/* Allocate tag if not present */
-
-	tag = sc->request->tag;
-	if (unlikely(tag < 0)) {
+	/* The last tag is reserved for device reset */
+	sc = scsi_host_find_tag(sdev->host, fnic->fnic_max_tag_id - 1);
+	io_lock = fnic_io_lock_hash(fnic, sc);
+	spin_lock_irqsave(io_lock, flags);
+	if (CMD_SP(sc)) {
 		/*
-		 * XXX(hch): current the midlayer fakes up a struct
-		 * request for the explicit reset ioctls, and those
-		 * don't have a tag allocated to them.  The below
-		 * code pokes into midlayer structures to paper over
-		 * this design issue, but that won't work for blk-mq.
-		 *
-		 * Either someone who can actually test the hardware
-		 * will have to come up with a similar hack for the
-		 * blk-mq case, or we'll have to bite the bullet and
-		 * fix the way the EH ioctls work for real, but until
-		 * that happens we fail these explicit requests here.
+		 * Reset tag busy
 		 */
-
-		tag = fnic_scsi_host_start_tag(fnic, sc);
-		if (unlikely(tag == SCSI_NO_TAG))
-			goto fnic_device_reset_end;
-		tag_gen_flag = 1;
-		new_sc = 1;
+		spin_unlock_irqrestore(io_lock, flags);
+		goto fnic_device_reset_end;
 	}
-	io_lock = fnic_io_lock_hash(fnic, sc);
-	spin_lock_irqsave(io_lock, flags);
-	io_req = (struct fnic_io_req *)CMD_SP(sc);
-
-	/*
-	 * If there is a io_req attached to this command, then use it,
-	 * else allocate a new one.
-	 */
+	io_req = mempool_alloc(fnic->io_req_pool, GFP_ATOMIC);
 	if (!io_req) {
-		io_req = mempool_alloc(fnic->io_req_pool, GFP_ATOMIC);
-		if (!io_req) {
-			spin_unlock_irqrestore(io_lock, flags);
-			goto fnic_device_reset_end;
-		}
-		memset(io_req, 0, sizeof(*io_req));
-		io_req->port_id = rport->port_id;
-		CMD_SP(sc) = (char *)io_req;
+		spin_unlock_irqrestore(io_lock, flags);
+		goto fnic_device_reset_end;
 	}
+	memset(io_req, 0, sizeof(*io_req));
+	io_req->port_id = rport->port_id;
+	CMD_SP(sc) = (char *)io_req;
 	io_req->dr_done = &tm_done;
+
+	CMD_FLAGS(sc) = FNIC_DEVICE_RESET;
 	CMD_STATE(sc) = FNIC_IOREQ_CMD_PENDING;
 	CMD_LR_STATUS(sc) = FCPIO_INVALID_CODE;
 	spin_unlock_irqrestore(io_lock, flags);
@@ -2538,7 +2512,7 @@ int fnic_device_reset(struct scsi_cmnd *sc)
 	 * the lun reset cmd. If all cmds get cleaned, the lun reset
 	 * succeeds
 	 */
-	if (fnic_clean_pending_aborts(fnic, sc, new_sc)) {
+	if (fnic_clean_pending_aborts(fnic, sc)) {
 		spin_lock_irqsave(io_lock, flags);
 		io_req = (struct fnic_io_req *)CMD_SP(sc);
 		FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
@@ -2575,10 +2549,6 @@ int fnic_device_reset(struct scsi_cmnd *sc)
 		  (u64)sc->cmnd[4] << 8 | sc->cmnd[5]),
 		  (((u64)CMD_FLAGS(sc) << 32) | CMD_STATE(sc)));
 
-	/* free tag if it is allocated */
-	if (unlikely(tag_gen_flag))
-		fnic_scsi_host_end_tag(fnic, sc);
-
 	FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
 		      "Returning from device reset %s\n",
 		      (ret == SUCCESS) ?
-- 
1.8.5.6

  parent reply	other threads:[~2017-06-28  8:33 UTC|newest]

Thread overview: 89+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-28  8:32 [PATCH 00/47] SCSI EH argument reshuffle part II Hannes Reinecke
2017-06-28  8:32 ` [PATCH 01/47] aacraid: split off functions to generate reset FIB Hannes Reinecke
2017-06-28  9:07   ` Johannes Thumshirn
2017-06-29 19:59   ` Raghava Aditya Renukunta
2017-06-28  8:32 ` [PATCH 02/47] aacraid: split off host reset Hannes Reinecke
2017-06-28  9:10   ` Johannes Thumshirn
2017-06-29 20:00   ` Raghava Aditya Renukunta
2017-06-28  8:32 ` [PATCH 03/47] aacraid: split off device, target, and bus reset Hannes Reinecke
2017-06-28  9:14   ` Johannes Thumshirn
2017-06-29 20:01   ` Raghava Aditya Renukunta
2017-06-28  8:32 ` [PATCH 04/47] aacraid: use aac_tmf_callback for reset fib Hannes Reinecke
2017-06-28 19:42   ` Dave Carroll
2017-06-29 20:06   ` Raghava Aditya Renukunta
2017-06-30  7:19     ` Hannes Reinecke
2017-06-28  8:32 ` [PATCH 05/47] aacraid: enable sending of TMFs from aac_hba_send() Hannes Reinecke
2017-06-28  9:17   ` Johannes Thumshirn
2017-06-29 20:07   ` Raghava Aditya Renukunta
2017-06-28  8:32 ` [PATCH 06/47] aacraid: add fib flag to mark scsi command callback Hannes Reinecke
2017-06-28  9:18   ` Johannes Thumshirn
2017-06-29 20:07   ` Raghava Aditya Renukunta
2017-06-28  8:32 ` [PATCH 07/47] aacraid: complete all commands during bus reset Hannes Reinecke
2017-06-28  9:19   ` Johannes Thumshirn
2017-06-29 20:07   ` Raghava Aditya Renukunta
2017-06-28  8:32 ` [PATCH 08/47] sym53c8xx_2: split off bus reset from host reset Hannes Reinecke
2017-06-28  9:19   ` Johannes Thumshirn
2017-06-28  9:25   ` Johannes Thumshirn
2017-06-28  8:32 ` [PATCH 09/47] zfcp: open-code fc_block_scsi_eh() for " Hannes Reinecke
2017-07-24 16:18   ` Steffen Maier
2017-07-24 18:01     ` Hannes Reinecke
2017-07-24 16:24   ` Steffen Maier
2017-06-28  8:32 ` [PATCH 10/47] ips: Do not try to abort command from " Hannes Reinecke
2017-06-28  9:31   ` Johannes Thumshirn
2017-06-28  8:32 ` [PATCH 11/47] snic: reserve tag for TMF Hannes Reinecke
2017-06-28  9:37   ` Johannes Thumshirn
2017-06-28  8:32 ` [PATCH 12/47] qla1280: separate out host reset function from qla1280_error_action() Hannes Reinecke
2017-06-28  9:39   ` Johannes Thumshirn
2017-06-28  8:32 ` [PATCH 13/47] megaraid: pass in NULL scb for host reset Hannes Reinecke
2017-06-28  9:39   ` Johannes Thumshirn
2017-06-28 13:41   ` Sumit Saxena
2017-06-28 15:30     ` Hannes Reinecke
2017-06-28 17:40       ` Kashyap Desai
     [not found]         ` <CAHtARFFTFMaUsVZ_KuYGr3hFcTuD5sf=h2+1RM6aj8yfpwsCWQ@mail.gmail.com>
2017-06-28 18:40           ` Christoph Hellwig
2017-06-29  5:53         ` Hannes Reinecke
2017-06-29  7:51           ` Sumit Saxena
2017-06-28  8:32 ` [PATCH 14/47] scsi: Use Scsi_Host as argument for eh_host_reset_handler Hannes Reinecke
2017-07-24 16:55   ` Steffen Maier
2017-06-28  8:32 ` [PATCH 15/47] scsi_transport_fc: Use fc_rport as argument for fc_block_scsi_eh Hannes Reinecke
2017-07-24 16:34   ` Steffen Maier
2017-06-28  8:32 ` [PATCH 16/47] mptfc: simplify mpt_fc_block_error_handler() Hannes Reinecke
2017-06-28  8:32 ` [PATCH 17/47] mptfusion: correct definitions for mptscsih_dev_reset() Hannes Reinecke
2017-06-28  8:32 ` [PATCH 18/47] mptfc: open-code mptfc_block_error_handler() for bus reset Hannes Reinecke
2017-06-28  8:32 ` [PATCH 19/47] pmcraid: Select device in pmcraid_eh_bus_reset_handler() Hannes Reinecke
2017-06-28  8:32 ` [PATCH 20/47] scsi: Use Scsi_Host and channel number as argument for eh_bus_reset_handler() Hannes Reinecke
2017-06-28  8:32 ` [PATCH 21/47] libiscsi: use cls_session as argument for target and session reset Hannes Reinecke
2017-06-28  8:32 ` [PATCH 22/47] bnx2fc: Do not rely on a scsi command when issueing lun or target reset Hannes Reinecke
2017-06-28  8:32 ` [PATCH 23/47] zfcp: do not rely on scsi command for debugging message Hannes Reinecke
2017-06-28  8:32 ` [PATCH 24/47] zfcp: use scsi device as argument for zfcp_task_mgmt_function() Hannes Reinecke
2017-07-24 17:15   ` Steffen Maier
2017-07-25 14:14     ` Hannes Reinecke
2017-06-28  8:32 ` [PATCH 25/47] ibmvfc: open-code reset loop for target reset Hannes Reinecke
2017-06-28  8:32 ` [PATCH 26/47] lpfc: use rport as argument for lpfc_send_taskmgmt() Hannes Reinecke
2017-06-28  8:32 ` [PATCH 27/47] lpfc: use rport as argument for lpfc_chk_tgt_mapped() Hannes Reinecke
2017-06-28  8:32 ` [PATCH 28/47] qla2xxx: open-code qla2xxx_generic_reset() Hannes Reinecke
2017-06-28  8:32 ` [PATCH 29/47] qedf: use fc rport as argument for qedf_initiate_tmf() Hannes Reinecke
2017-06-28  8:32 ` [PATCH 30/47] sym53c8xx_2: rework reset handling Hannes Reinecke
2017-06-28  8:32 ` [PATCH 31/47] bfa: Do not use scsi command to signal TMF status Hannes Reinecke
2017-06-28  8:32 ` [PATCH 32/47] scsi: Use scsi_target as argument for eh_target_reset_handler() Hannes Reinecke
2017-07-24 18:10   ` Steffen Maier
2017-07-25 14:19     ` Hannes Reinecke
2017-08-02 16:52       ` Steffen Maier
2017-06-28  8:32 ` [PATCH 33/47] cxlflash: use dedicated reset command in send_tmf() Hannes Reinecke
2017-06-28 16:29   ` Matthew R. Ochs
2017-06-28  8:33 ` [PATCH 34/47] aha152x: look for stuck command when resetting device Hannes Reinecke
2017-06-28  8:33 ` Hannes Reinecke [this message]
2017-06-28  8:33 ` [PATCH 36/47] a1000u2w: do not rely on the command for inia100_device_reset() Hannes Reinecke
2017-06-28  8:33 ` [PATCH 37/47] aic79xx: use scsi device as argument for BUILD_SCSIID() Hannes Reinecke
2017-06-28  8:33 ` [PATCH 38/47] aic7xxx: " Hannes Reinecke
2017-06-28  8:33 ` [PATCH 39/47] aic79xx: do not reference scsi command when resetting device Hannes Reinecke
2017-06-28  8:33 ` [PATCH 40/47] aic7xxx: " Hannes Reinecke
2017-06-28  8:33 ` [PATCH 41/47] xen-scsifront: add scsi device as argument to scsifront_do_request() Hannes Reinecke
2017-06-28  8:33 ` [PATCH 42/47] xen-scsifront: call scsifront_action_handler() with a NULL command argument Hannes Reinecke
2017-06-28  8:33 ` [PATCH 43/47] fas216: Rework device reset to not rely on SCSI command pointer Hannes Reinecke
2017-06-28  8:33 ` [PATCH 44/47] csiostor: use separate TMF command Hannes Reinecke
2017-06-28  8:33 ` [PATCH 45/47] snic: use dedicated device reset command Hannes Reinecke
2017-06-28  8:33 ` [PATCH 46/47] scsi: Move eh_device_reset_handler() to use scsi_device as argument Hannes Reinecke
2017-07-24 18:42   ` Steffen Maier
2017-06-28  8:33 ` [PATCH 47/47] scsi: Do not allocate scsi command in scsi_ioctl_reset() Hannes Reinecke
2017-06-28 14:06 ` [PATCH 00/47] SCSI EH argument reshuffle part II Christoph Hellwig
2018-01-08 11:26 ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1498638793-44672-36-git-send-email-hare@suse.de \
    --to=hare@suse.de \
    --cc=hare@suse.com \
    --cc=hch@lst.de \
    --cc=james.bottomley@hansenpartnership.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.