All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steffen Maier <maier@linux.vnet.ibm.com>
To: linux-scsi@vger.kernel.org, Hannes Reinecke <hare@suse.de>
Cc: linux-s390@vger.kernel.org,
	Steffen Maier <maier@linux.vnet.ibm.com>,
	Benjamin Block <bblock@linux.vnet.ibm.com>
Subject: [RFC 5/9] zfcp: decouple SCSI setup of TMF from scsi_cmnd
Date: Tue, 25 Jul 2017 16:14:23 +0200	[thread overview]
Message-ID: <20170725141427.35258-6-maier@linux.vnet.ibm.com> (raw)
In-Reply-To: <20170725141427.35258-1-maier@linux.vnet.ibm.com>

Actually change the signature of zfcp_fsf_fcp_task_mgmt().
Since it was prepared in the previous patch, we only need to delete
some local auto variables which are now the intended arguments.

Refactor zfcp_scsi_forget_cmnds() to now take a mandatory zfcp_port
and an optional zfcp_scsi_dev, which can be NULL for target reset,
instead of a mandatory zfcp_scsi_dev.

Prepare zfcp_fsf_fcp_task_mgmt's caller zfcp_task_mgmt_function()
to have its function body only depend on a mandatory zfcp_port
and an optional scsi_device, which can be NULL for target reset.

Signed-off-by: Steffen Maier <maier@linux.vnet.ibm.com>
---
 drivers/s390/scsi/zfcp_ext.h  |  4 +++-
 drivers/s390/scsi/zfcp_fsf.c  | 15 ++++++++-------
 drivers/s390/scsi/zfcp_scsi.c | 28 +++++++++++++++++++---------
 3 files changed, 30 insertions(+), 17 deletions(-)

diff --git a/drivers/s390/scsi/zfcp_ext.h b/drivers/s390/scsi/zfcp_ext.h
index f3101bc5d1bc..26772b0c1c39 100644
--- a/drivers/s390/scsi/zfcp_ext.h
+++ b/drivers/s390/scsi/zfcp_ext.h
@@ -118,7 +118,9 @@ extern int zfcp_fsf_send_els(struct zfcp_adapter *, u32,
 			     struct zfcp_fsf_ct_els *, unsigned int);
 extern int zfcp_fsf_fcp_cmnd(struct scsi_cmnd *);
 extern void zfcp_fsf_req_free(struct zfcp_fsf_req *);
-extern struct zfcp_fsf_req *zfcp_fsf_fcp_task_mgmt(struct scsi_cmnd *, u8);
+extern struct zfcp_fsf_req *zfcp_fsf_fcp_task_mgmt(struct zfcp_port *port,
+						   struct scsi_device *sdev,
+						   u8 tm_flags);
 extern struct zfcp_fsf_req *zfcp_fsf_abort_fcp_cmnd(struct scsi_cmnd *);
 extern void zfcp_fsf_reqid_check(struct zfcp_qdio *, int);
 
diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c
index 2dc7d2a6f6ea..7cc2d7ee1f56 100644
--- a/drivers/s390/scsi/zfcp_fsf.c
+++ b/drivers/s390/scsi/zfcp_fsf.c
@@ -2329,19 +2329,20 @@ static void zfcp_fsf_fcp_task_mgmt_handler(struct zfcp_fsf_req *req)
 }
 
 /**
- * zfcp_fsf_fcp_task_mgmt - send SCSI task management command
- * @scmnd: SCSI command to send the task management command for
- * @tm_flags: unsigned byte for task management flags
- * Returns: on success pointer to struct fsf_req, NULL otherwise
+ * zfcp_fsf_fcp_task_mgmt() - Send SCSI task management command (TMF).
+ * @port: Pointer to zfcp port as scope for TMF.
+ * @sdev: Pointer to scsi device if LUN Reset TMF, or %NULL.
+ * @tm_flags: Unsigned byte for task management flags.
+ *
+ * Return: On success pointer to struct fsf_req, %NULL otherwise.
  */
-struct zfcp_fsf_req *zfcp_fsf_fcp_task_mgmt(struct scsi_cmnd *scmnd,
+struct zfcp_fsf_req *zfcp_fsf_fcp_task_mgmt(struct zfcp_port *port,
+					    struct scsi_device *sdev,
 					    u8 tm_flags)
 {
 	struct zfcp_fsf_req *req = NULL;
 	struct fcp_cmnd *fcp_cmnd;
-	struct scsi_device *sdev = scmnd->device;
 	struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev);
-	struct zfcp_port *port = zfcp_sdev->port;
 	struct zfcp_qdio *qdio = port->adapter->qdio;
 
 	if (unlikely(!(atomic_read(&port->status) &
diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c
index cd0f811452b7..05c823ccb959 100644
--- a/drivers/s390/scsi/zfcp_scsi.c
+++ b/drivers/s390/scsi/zfcp_scsi.c
@@ -234,12 +234,20 @@ static void zfcp_scsi_forget_cmnd(struct zfcp_fsf_req *old_req, void *data)
 	old_req->data = NULL;
 }
 
-static void zfcp_scsi_forget_cmnds(struct zfcp_scsi_dev *zsdev, u8 tm_flags)
+/**
+ * zfcp_scsi_forget_cmnds() - Forget pending SCSI requests on given scope.
+ * @port: Pointer to zfcp port indicating scope.
+ * @zsdev: Pointer to zfcp scsi dev as scope, or %NULL if scope is only port.
+ * @tm_flags: Task management flags,
+ *            here we only handle %FCP_TMF_TGT_RESET or %FCP_TMF_LUN_RESET.
+ */
+static void zfcp_scsi_forget_cmnds(struct zfcp_port *port,
+				   struct zfcp_scsi_dev *zsdev, u8 tm_flags)
 {
-	struct zfcp_adapter *adapter = zsdev->port->adapter;
+	struct zfcp_adapter *adapter = port->adapter;
 	struct zfcp_scsi_req_filter filter = {
 		.tmf_scope = FCP_TMF_TGT_RESET,
-		.port_handle = zsdev->port->handle,
+		.port_handle = port->handle,
 	};
 	unsigned long flags;
 
@@ -260,19 +268,21 @@ static void zfcp_scsi_forget_cmnds(struct zfcp_scsi_dev *zsdev, u8 tm_flags)
 
 static int zfcp_task_mgmt_function(struct scsi_cmnd *scpnt, u8 tm_flags)
 {
-	struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(scpnt->device);
-	struct zfcp_adapter *adapter = zfcp_sdev->port->adapter;
-	unsigned int scsi_id = zfcp_sdev->port->starget_id;
+	struct scsi_device *sdev = scpnt->device;
+	struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev);
+	struct zfcp_port *port = zfcp_sdev->port;
+	struct zfcp_adapter *adapter = port->adapter;
+	unsigned int scsi_id = port->starget_id;
 	u64 scsi_lun = ZFCP_DBF_INVALID_LUN;
 	struct zfcp_fsf_req *fsf_req = NULL;
 	int retval = SUCCESS, ret;
 	int retry = 3;
 
 	if (tm_flags == FCP_TMF_LUN_RESET)
-		scsi_lun = scpnt->device->lun;
+		scsi_lun = sdev->lun;
 
 	while (retry--) {
-		fsf_req = zfcp_fsf_fcp_task_mgmt(scpnt, tm_flags);
+		fsf_req = zfcp_fsf_fcp_task_mgmt(port, sdev, tm_flags);
 		if (fsf_req)
 			break;
 
@@ -306,7 +316,7 @@ static int zfcp_task_mgmt_function(struct scsi_cmnd *scpnt, u8 tm_flags)
 	} else {
 		zfcp_dbf_scsi_devreset("okay", adapter, tm_flags, fsf_req,
 				       scsi_id, scsi_lun);
-		zfcp_scsi_forget_cmnds(zfcp_sdev, tm_flags);
+		zfcp_scsi_forget_cmnds(port, zfcp_sdev, tm_flags);
 	}
 
 	zfcp_fsf_req_free(fsf_req);
-- 
2.11.2

  parent reply	other threads:[~2017-07-25 14:14 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-25 14:14 [RFC 0/9] zfcp: decouple scsi_eh callbacks from scsi_cmnd Steffen Maier
2017-07-25 14:14 ` [RFC 1/9] zfcp: drop unsuitable scsi_cmnd usage from SCSI traces for scsi_eh / TMF Steffen Maier
2017-07-26  5:50   ` Hannes Reinecke
2017-07-25 14:14 ` [RFC 2/9] zfcp: decouple TMF response handler from scsi_cmnd Steffen Maier
2017-07-26  5:52   ` Hannes Reinecke
2017-08-01 16:22   ` Steffen Maier
2017-07-25 14:14 ` [RFC 3/9] zfcp: split FCP_CMND IU setup between SCSI I/O and TMF again Steffen Maier
2017-07-26  5:53   ` Hannes Reinecke
2017-07-25 14:14 ` [RFC 4/9] zfcp: decouple FSF request setup of TMF from scsi_cmnd Steffen Maier
2017-07-26  5:55   ` Hannes Reinecke
2017-08-04 10:33   ` Steffen Maier
2017-07-25 14:14 ` Steffen Maier [this message]
2017-07-26  5:56   ` [RFC 5/9] zfcp: decouple SCSI " Hannes Reinecke
2017-07-25 14:14 ` [RFC 6/9] scsi: fc: start decoupling fc_block_scsi_eh " Steffen Maier
2017-07-26  5:58   ` Hannes Reinecke
2017-08-07 17:08   ` Martin K. Petersen
2017-07-25 14:14 ` [RFC 7/9] zfcp: use fc_block_rport for TMFs and host reset to decouple " Steffen Maier
2017-07-26  6:14   ` Hannes Reinecke
2017-07-25 14:14 ` [RFC 8/9] zfcp: fix waiting for rport(s) unblock in eh_host_reset_handler Steffen Maier
2017-07-26  6:16   ` Hannes Reinecke
2017-07-25 14:14 ` [RFC 9/9] zfcp: decouple our scsi_eh callbacks from scsi_cmnd Steffen Maier
2017-07-26  6:16   ` Hannes Reinecke

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=20170725141427.35258-6-maier@linux.vnet.ibm.com \
    --to=maier@linux.vnet.ibm.com \
    --cc=bblock@linux.vnet.ibm.com \
    --cc=hare@suse.de \
    --cc=linux-s390@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    /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.