diff mbox series

[RFC,08/10] ibm,loop,vhost,xenscsi: add close_session callouts

Message ID 1593232509-13720-9-git-send-email-michael.christie@oracle.com (mailing list archive)
State Changes Requested
Headers show
Series target: add configfs interface | expand

Commit Message

Mike Christie June 27, 2020, 4:35 a.m. UTC
Call the fabric modules drop nexus functions from the close_session
callout.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
---

 drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c | 14 +++++++++++---
 drivers/target/loopback/tcm_loop.c       | 17 ++++++++++++-----
 drivers/usb/gadget/function/f_tcm.c      | 17 ++++++++++++-----
 drivers/vhost/scsi.c                     | 16 ++++++++++++----
 drivers/xen/xen-scsiback.c               | 16 ++++++++++++----
 5 files changed, 59 insertions(+), 21 deletions(-)
diff mbox series

Patch

diff --git a/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c b/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c
index a817524..81f9649 100644
--- a/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c
+++ b/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c
@@ -2239,10 +2239,12 @@  static int ibmvscsis_make_nexus(struct ibmvscsis_tport *tport)
 	return rc;
 }
 
-static int ibmvscsis_drop_nexus(struct ibmvscsis_tport *tport)
+static int ibmvscsis_drop_nexus(struct se_portal_group *se_tpg)
 {
-	struct se_session *se_sess;
+	struct ibmvscsis_tport *tport =
+		container_of(se_tpg, struct ibmvscsis_tport, se_tpg);
 	struct ibmvscsis_nexus *nexus;
+	struct se_session *se_sess;
 
 	nexus = tport->ibmv_nexus;
 	if (!nexus)
@@ -2262,6 +2264,11 @@  static int ibmvscsis_drop_nexus(struct ibmvscsis_tport *tport)
 	return 0;
 }
 
+static int ibmvscsis_close_session(struct se_session *se_sess)
+{
+	return ibmvscsis_drop_nexus(se_sess->se_tpg);
+}
+
 /**
  * ibmvscsis_srp_login() - Process an SRP Login Request
  * @vscsi:	Pointer to our adapter structure
@@ -3934,7 +3941,7 @@  static void ibmvscsis_drop_tpg(struct se_portal_group *se_tpg)
 	/*
 	 * Release the virtual I_T Nexus for this ibmvscsis TPG
 	 */
-	ibmvscsis_drop_nexus(tport);
+	ibmvscsis_drop_nexus(se_tpg);
 	/*
 	 * Deregister the se_tpg from TCM..
 	 */
@@ -4036,6 +4043,7 @@  static ssize_t ibmvscsis_tpg_enable_store(struct config_item *item,
 	.queue_status			= ibmvscsis_queue_status,
 	.queue_tm_rsp			= ibmvscsis_queue_tm_rsp,
 	.aborted_task			= ibmvscsis_aborted_task,
+	.close_session			= ibmvscsis_close_session,
 	/*
 	 * Setup function pointers for logic in target_core_fabric_configfs.c
 	 */
diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c
index 570dff2..d5e616e 100644
--- a/drivers/target/loopback/tcm_loop.c
+++ b/drivers/target/loopback/tcm_loop.c
@@ -749,11 +749,12 @@  static int tcm_loop_make_nexus(
 	return 0;
 }
 
-static int tcm_loop_drop_nexus(
-	struct tcm_loop_tpg *tpg)
+static int tcm_loop_drop_nexus(struct se_portal_group *se_tpg)
 {
-	struct se_session *se_sess;
+	struct tcm_loop_tpg *tpg = container_of(se_tpg, struct tcm_loop_tpg,
+						tl_se_tpg);
 	struct tcm_loop_nexus *tl_nexus;
+	struct se_session *se_sess;
 
 	mutex_lock(&tpg->tl_nexus_mutex);
 	tl_nexus = tpg->tl_nexus;
@@ -789,6 +790,11 @@  static int tcm_loop_drop_nexus(
 	return 0;
 }
 
+static int tcm_loop_close_session(struct se_session *se_sess)
+{
+	return tcm_loop_drop_nexus(se_sess->se_tpg);
+}
+
 /* End items for tcm_loop_nexus_cit */
 
 static ssize_t tcm_loop_tpg_nexus_show(struct config_item *item, char *page)
@@ -826,7 +832,7 @@  static ssize_t tcm_loop_tpg_nexus_store(struct config_item *item,
 	 * Shutdown the active I_T nexus if 'NULL' is passed..
 	 */
 	if (!strncmp(page, "NULL", 4)) {
-		ret = tcm_loop_drop_nexus(tl_tpg);
+		ret = tcm_loop_drop_nexus(se_tpg);
 		return (!ret) ? count : ret;
 	}
 	/*
@@ -1017,7 +1023,7 @@  static void tcm_loop_drop_naa_tpg(
 	/*
 	 * Release the I_T Nexus for the Virtual target link if present
 	 */
-	tcm_loop_drop_nexus(tl_tpg);
+	tcm_loop_drop_nexus(se_tpg);
 	/*
 	 * Deregister the tl_tpg as a emulated TCM Target Endpoint
 	 */
@@ -1155,6 +1161,7 @@  static ssize_t tcm_loop_wwn_version_show(struct config_item *item, char *page)
 	.queue_status			= tcm_loop_queue_status,
 	.queue_tm_rsp			= tcm_loop_queue_tm_rsp,
 	.aborted_task			= tcm_loop_aborted_task,
+	.close_session			= tcm_loop_close_session,
 	.fabric_make_wwn		= tcm_loop_make_scsi_hba,
 	.fabric_drop_wwn		= tcm_loop_drop_scsi_hba,
 	.fabric_make_tpg		= tcm_loop_make_naa_tpg,
diff --git a/drivers/usb/gadget/function/f_tcm.c b/drivers/usb/gadget/function/f_tcm.c
index e66884f..ed449ab 100644
--- a/drivers/usb/gadget/function/f_tcm.c
+++ b/drivers/usb/gadget/function/f_tcm.c
@@ -1415,7 +1415,7 @@  static struct se_portal_group *usbg_make_tpg(struct se_wwn *wwn,
 	return ERR_PTR(ret);
 }
 
-static int tcm_usbg_drop_nexus(struct usbg_tpg *);
+static int tcm_usbg_drop_nexus(struct se_portal_group *);
 
 static void usbg_drop_tpg(struct se_portal_group *se_tpg)
 {
@@ -1424,7 +1424,7 @@  static void usbg_drop_tpg(struct se_portal_group *se_tpg)
 	unsigned i;
 	struct f_tcm_opts *opts;
 
-	tcm_usbg_drop_nexus(tpg);
+	tcm_usbg_drop_nexus(se_tpg);
 	core_tpg_deregister(se_tpg);
 	destroy_workqueue(tpg->workqueue);
 
@@ -1597,10 +1597,11 @@  static int tcm_usbg_make_nexus(struct usbg_tpg *tpg, char *name)
 	return ret;
 }
 
-static int tcm_usbg_drop_nexus(struct usbg_tpg *tpg)
+static int tcm_usbg_drop_nexus(struct se_portal_group *se_tpg)
 {
-	struct se_session *se_sess;
+	struct usbg_tpg *tpg = container_of(se_tpg, struct usbg_tpg, se_tpg);
 	struct tcm_usbg_nexus *tv_nexus;
+	struct se_session *se_sess;
 	int ret = -ENODEV;
 
 	mutex_lock(&tpg->tpg_mutex);
@@ -1635,6 +1636,11 @@  static int tcm_usbg_drop_nexus(struct usbg_tpg *tpg)
 	return ret;
 }
 
+static int tcm_usbg_close_session(struct se_session *se_sess)
+{
+	return tcm_usbg_drop_nexus(se_sess->se_tpg);
+}
+
 static ssize_t tcm_usbg_tpg_nexus_store(struct config_item *item,
 		const char *page, size_t count)
 {
@@ -1644,7 +1650,7 @@  static ssize_t tcm_usbg_tpg_nexus_store(struct config_item *item,
 	int ret;
 
 	if (!strncmp(page, "NULL", 4)) {
-		ret = tcm_usbg_drop_nexus(tpg);
+		ret = tcm_usbg_drop_nexus(se_tpg);
 		return (!ret) ? count : ret;
 	}
 	if (strlen(page) >= USBG_NAMELEN) {
@@ -1723,6 +1729,7 @@  static int usbg_check_stop_free(struct se_cmd *se_cmd)
 	.queue_tm_rsp			= usbg_queue_tm_rsp,
 	.aborted_task			= usbg_aborted_task,
 	.check_stop_free		= usbg_check_stop_free,
+	.close_session			= tcm_usbg_close_session,
 
 	.fabric_make_wwn		= usbg_make_tport,
 	.fabric_drop_wwn		= usbg_drop_tport,
diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
index 7896e69..d30b8da 100644
--- a/drivers/vhost/scsi.c
+++ b/drivers/vhost/scsi.c
@@ -1972,10 +1972,12 @@  static int vhost_scsi_make_nexus(struct vhost_scsi_tpg *tpg,
 	return 0;
 }
 
-static int vhost_scsi_drop_nexus(struct vhost_scsi_tpg *tpg)
+static int vhost_scsi_drop_nexus(struct se_portal_group *se_tpg)
 {
-	struct se_session *se_sess;
+	struct vhost_scsi_tpg *tpg = container_of(se_tpg, struct vhost_scsi_tpg,
+						  se_tpg);
 	struct vhost_scsi_nexus *tv_nexus;
+	struct se_session *se_sess;
 
 	mutex_lock(&tpg->tv_tpg_mutex);
 	tv_nexus = tpg->tpg_nexus;
@@ -2022,6 +2024,11 @@  static int vhost_scsi_drop_nexus(struct vhost_scsi_tpg *tpg)
 	return 0;
 }
 
+static int vhost_scsi_close_session(struct se_session *se_sess)
+{
+	return vhost_scsi_drop_nexus(se_sess->se_tpg);
+}
+
 static ssize_t vhost_scsi_tpg_nexus_show(struct config_item *item, char *page)
 {
 	struct se_portal_group *se_tpg = to_tpg(item);
@@ -2056,7 +2063,7 @@  static ssize_t vhost_scsi_tpg_nexus_store(struct config_item *item,
 	 * Shutdown the active I_T nexus if 'NULL' is passed..
 	 */
 	if (!strncmp(page, "NULL", 4)) {
-		ret = vhost_scsi_drop_nexus(tpg);
+		ret = vhost_scsi_drop_nexus(se_tpg);
 		return (!ret) ? count : ret;
 	}
 	/*
@@ -2176,7 +2183,7 @@  static void vhost_scsi_drop_tpg(struct se_portal_group *se_tpg)
 	/*
 	 * Release the virtual I_T Nexus for this vhost TPG
 	 */
-	vhost_scsi_drop_nexus(tpg);
+	vhost_scsi_drop_nexus(se_tpg);
 	/*
 	 * Deregister the se_tpg from TCM..
 	 */
@@ -2294,6 +2301,7 @@  static void vhost_scsi_drop_tport(struct se_wwn *wwn)
 	.queue_status			= vhost_scsi_queue_status,
 	.queue_tm_rsp			= vhost_scsi_queue_tm_rsp,
 	.aborted_task			= vhost_scsi_aborted_task,
+	.close_session			= vhost_scsi_close_session,
 	/*
 	 * Setup callers for generic logic in target_core_fabric_configfs.c
 	 */
diff --git a/drivers/xen/xen-scsiback.c b/drivers/xen/xen-scsiback.c
index f0a8fc7..ffd1a7a 100644
--- a/drivers/xen/xen-scsiback.c
+++ b/drivers/xen/xen-scsiback.c
@@ -1538,10 +1538,12 @@  static int scsiback_make_nexus(struct scsiback_tpg *tpg,
 	return ret;
 }
 
-static int scsiback_drop_nexus(struct scsiback_tpg *tpg)
+static int scsiback_drop_nexus(struct se_portal_group *se_tpg)
 {
-	struct se_session *se_sess;
+	struct scsiback_tpg *tpg = container_of(se_tpg, struct scsiback_tpg,
+						se_tpg);
 	struct scsiback_nexus *tv_nexus;
+	struct se_session *se_sess;
 
 	mutex_lock(&tpg->tv_tpg_mutex);
 	tv_nexus = tpg->tpg_nexus;
@@ -1585,6 +1587,11 @@  static int scsiback_drop_nexus(struct scsiback_tpg *tpg)
 	return 0;
 }
 
+static int scsiback_close_session(struct se_session *se_sess)
+{
+	return scsiback_drop_nexus(se_sess->se_tpg);
+}
+
 static ssize_t scsiback_tpg_nexus_show(struct config_item *item, char *page)
 {
 	struct se_portal_group *se_tpg = to_tpg(item);
@@ -1619,7 +1626,7 @@  static ssize_t scsiback_tpg_nexus_store(struct config_item *item,
 	 * Shutdown the active I_T nexus if 'NULL' is passed.
 	 */
 	if (!strncmp(page, "NULL", 4)) {
-		ret = scsiback_drop_nexus(tpg);
+		ret = scsiback_drop_nexus(se_tpg);
 		return (!ret) ? count : ret;
 	}
 	/*
@@ -1776,7 +1783,7 @@  static void scsiback_drop_tpg(struct se_portal_group *se_tpg)
 	/*
 	 * Release the virtual I_T Nexus for this xen-pvscsi TPG
 	 */
-	scsiback_drop_nexus(tpg);
+	scsiback_drop_nexus(se_tpg);
 	/*
 	 * Deregister the se_tpg from TCM.
 	 */
@@ -1814,6 +1821,7 @@  static int scsiback_check_false(struct se_portal_group *se_tpg)
 	.queue_status			= scsiback_queue_status,
 	.queue_tm_rsp			= scsiback_queue_tm_rsp,
 	.aborted_task			= scsiback_aborted_task,
+	.close_session			= scsiback_close_session,
 	/*
 	 * Setup callers for generic logic in target_core_fabric_configfs.c
 	 */