diff mbox series

[01/11] target: pass in fabric ops to session creation

Message ID 20210204113513.93204-2-michael.christie@oracle.com
State New
Headers show
Series target: fix cmd plugging and completion | expand

Commit Message

Mike Christie Feb. 4, 2021, 11:35 a.m. UTC
The next patch will create a session level submission work queue if
the drivers fabric ops implements a new callout. This patch just
converts the target code to take the new fabric ops arg so we can
check if the callout is implemented and then call it in other functions
when we have only the se_session available to us.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
---
 drivers/target/iscsi/iscsi_target_login.c |  2 +-
 drivers/target/target_core_transport.c    | 24 ++++++++++++++++-------
 drivers/target/target_core_xcopy.c        |  2 +-
 include/target/target_core_base.h         |  1 +
 include/target/target_core_fabric.h       |  6 ++++--
 5 files changed, 24 insertions(+), 11 deletions(-)
diff mbox series

Patch

diff --git a/drivers/target/iscsi/iscsi_target_login.c b/drivers/target/iscsi/iscsi_target_login.c
index 1a9c50401bdb..ddf0c3b13671 100644
--- a/drivers/target/iscsi/iscsi_target_login.c
+++ b/drivers/target/iscsi/iscsi_target_login.c
@@ -317,7 +317,7 @@  static int iscsi_login_zero_tsih_s1(
 		goto free_id;
 	}
 
-	sess->se_sess = transport_alloc_session(TARGET_PROT_NORMAL);
+	sess->se_sess = transport_alloc_session(&iscsi_ops, TARGET_PROT_NORMAL);
 	if (IS_ERR(sess->se_sess)) {
 		iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR,
 				ISCSI_LOGIN_STATUS_NO_RESOURCES);
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index 93ea17cbad79..7c5d37bac561 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -220,11 +220,13 @@  static void target_release_sess_cmd_refcnt(struct percpu_ref *ref)
 
 /**
  * transport_init_session - initialize a session object
+ * @tfo: target core fabric ops
  * @se_sess: Session object pointer.
  *
  * The caller must have zero-initialized @se_sess before calling this function.
  */
-int transport_init_session(struct se_session *se_sess)
+int transport_init_session(const struct target_core_fabric_ops *tfo,
+			   struct se_session *se_sess)
 {
 	INIT_LIST_HEAD(&se_sess->sess_list);
 	INIT_LIST_HEAD(&se_sess->sess_acl_list);
@@ -232,6 +234,7 @@  int transport_init_session(struct se_session *se_sess)
 	init_waitqueue_head(&se_sess->cmd_count_wq);
 	init_completion(&se_sess->stop_done);
 	atomic_set(&se_sess->stopped, 0);
+	se_sess->tfo = tfo;
 	return percpu_ref_init(&se_sess->cmd_count,
 			       target_release_sess_cmd_refcnt, 0, GFP_KERNEL);
 }
@@ -252,9 +255,12 @@  void transport_uninit_session(struct se_session *se_sess)
 
 /**
  * transport_alloc_session - allocate a session object and initialize it
+ * @tfo: target core fabric ops
  * @sup_prot_ops: bitmask that defines which T10-PI modes are supported.
  */
-struct se_session *transport_alloc_session(enum target_prot_op sup_prot_ops)
+struct se_session *
+transport_alloc_session(const struct target_core_fabric_ops *tfo,
+			enum target_prot_op sup_prot_ops)
 {
 	struct se_session *se_sess;
 	int ret;
@@ -265,7 +271,8 @@  struct se_session *transport_alloc_session(enum target_prot_op sup_prot_ops)
 				" se_sess_cache\n");
 		return ERR_PTR(-ENOMEM);
 	}
-	ret = transport_init_session(se_sess);
+
+	ret = transport_init_session(tfo, se_sess);
 	if (ret < 0) {
 		kmem_cache_free(se_sess_cache, se_sess);
 		return ERR_PTR(ret);
@@ -311,13 +318,15 @@  EXPORT_SYMBOL(transport_alloc_session_tags);
 
 /**
  * transport_init_session_tags - allocate a session and target driver private data
+ * @tfo: target core fabric ops
  * @tag_num:  Maximum number of in-flight commands between initiator and target.
  * @tag_size: Size in bytes of the private data a target driver associates with
  *	      each command.
  * @sup_prot_ops: bitmask that defines which T10-PI modes are supported.
  */
 static struct se_session *
-transport_init_session_tags(unsigned int tag_num, unsigned int tag_size,
+transport_init_session_tags(const struct target_core_fabric_ops *tfo,
+			    unsigned int tag_num, unsigned int tag_size,
 			    enum target_prot_op sup_prot_ops)
 {
 	struct se_session *se_sess;
@@ -334,7 +343,7 @@  transport_init_session_tags(unsigned int tag_num, unsigned int tag_size,
 		return ERR_PTR(-EINVAL);
 	}
 
-	se_sess = transport_alloc_session(sup_prot_ops);
+	se_sess = transport_alloc_session(tfo, sup_prot_ops);
 	if (IS_ERR(se_sess))
 		return se_sess;
 
@@ -442,9 +451,10 @@  target_setup_session(struct se_portal_group *tpg,
 	 * of I/O descriptor tags, go ahead and perform that setup now..
 	 */
 	if (tag_num != 0)
-		sess = transport_init_session_tags(tag_num, tag_size, prot_op);
+		sess = transport_init_session_tags(tpg->se_tpg_tfo, tag_num,
+						   tag_size, prot_op);
 	else
-		sess = transport_alloc_session(prot_op);
+		sess = transport_alloc_session(tpg->se_tpg_tfo, prot_op);
 
 	if (IS_ERR(sess))
 		return sess;
diff --git a/drivers/target/target_core_xcopy.c b/drivers/target/target_core_xcopy.c
index 44e15d7fb2f0..a7553712da25 100644
--- a/drivers/target/target_core_xcopy.c
+++ b/drivers/target/target_core_xcopy.c
@@ -472,7 +472,7 @@  int target_xcopy_setup_pt(void)
 	INIT_LIST_HEAD(&xcopy_pt_nacl.acl_list);
 	INIT_LIST_HEAD(&xcopy_pt_nacl.acl_sess_list);
 	memset(&xcopy_pt_sess, 0, sizeof(struct se_session));
-	ret = transport_init_session(&xcopy_pt_sess);
+	ret = transport_init_session(&xcopy_pt_tfo, &xcopy_pt_sess);
 	if (ret < 0)
 		goto destroy_wq;
 
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
index 54dcc0eb25fa..50103a22b0e2 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -628,6 +628,7 @@  struct se_session {
 	struct completion	stop_done;
 	void			*sess_cmd_map;
 	struct sbitmap_queue	sess_tag_pool;
+	const struct target_core_fabric_ops *tfo;
 };
 
 struct se_device;
diff --git a/include/target/target_core_fabric.h b/include/target/target_core_fabric.h
index d60a3eb7517a..cdf610838ba5 100644
--- a/include/target/target_core_fabric.h
+++ b/include/target/target_core_fabric.h
@@ -132,8 +132,10 @@  struct se_session *target_setup_session(struct se_portal_group *,
 				struct se_session *, void *));
 void target_remove_session(struct se_session *);
 
-int transport_init_session(struct se_session *se_sess);
-struct se_session *transport_alloc_session(enum target_prot_op);
+int transport_init_session(const struct target_core_fabric_ops *tfo,
+			   struct se_session *se_sess);
+struct se_session *transport_alloc_session(const struct target_core_fabric_ops *tfo,
+					   enum target_prot_op);
 int transport_alloc_session_tags(struct se_session *, unsigned int,
 		unsigned int);
 void	__transport_register_session(struct se_portal_group *,