All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Christie <michael.christie@oracle.com>
To: martin.petersen@oracle.com, linux-scsi@vger.kernel.org,
	target-devel@vger.kernel.org, mst@redhat.com,
	jasowang@redhat.com, stefanha@redhat.com,
	virtualization@lists.linux-foundation.org
Cc: Mike Christie <michael.christie@oracle.com>
Subject: [PATCH 01/11] target: pass in fabric ops to session creation
Date: Thu,  4 Feb 2021 05:35:03 -0600	[thread overview]
Message-ID: <20210204113513.93204-2-michael.christie@oracle.com> (raw)
In-Reply-To: <20210204113513.93204-1-michael.christie@oracle.com>

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 --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 *,
-- 
2.25.1


  reply	other threads:[~2021-02-04 11:38 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-04 11:35 [PATCH 00/11] target: fix cmd plugging and completion Mike Christie
2021-02-04 11:35 ` Mike Christie [this message]
2021-02-04 11:35 ` [PATCH 02/11] target: add workqueue cmd submission helper Mike Christie
2021-02-04 23:13   ` Chaitanya Kulkarni
2021-02-05  0:43     ` michael.christie
2021-02-05  1:50       ` Chaitanya Kulkarni
2021-02-04 11:35 ` [PATCH 03/11] tcm loop: use blk cmd allocator for se_cmds Mike Christie
2021-02-04 11:35 ` [PATCH 04/11] tcm loop: use lio wq cmd submission helper Mike Christie
2021-02-04 11:35 ` [PATCH 05/11] vhost scsi: " Mike Christie
2021-02-05 16:17   ` Michael S. Tsirkin
2021-02-05 16:17     ` Michael S. Tsirkin
2021-02-05 17:38     ` Mike Christie
2021-02-05 18:04       ` Mike Christie
2021-02-04 11:35 ` [PATCH 06/11] target: cleanup cmd flag bits Mike Christie
2021-02-04 23:15   ` Chaitanya Kulkarni
2021-02-04 11:35 ` [PATCH 07/11] target: fix backend plugging Mike Christie
2021-02-04 11:35 ` [PATCH 08/11] target iblock: add backend plug/unplug callouts Mike Christie
2021-02-04 23:23   ` Chaitanya Kulkarni
2021-02-05  0:45     ` michael.christie
2021-02-07  1:06   ` Chaitanya Kulkarni
2021-02-07  2:21     ` Bart Van Assche
2021-02-07  2:21       ` Bart Van Assche
2021-02-04 11:35 ` [PATCH 09/11] target_core_user: " Mike Christie
2021-02-04 23:25   ` Chaitanya Kulkarni
2021-02-07 21:37     ` Mike Christie
2021-02-04 11:35 ` [PATCH 10/11] target: replace work per cmd in completion path Mike Christie
2021-02-04 23:26   ` Chaitanya Kulkarni
2021-02-04 11:35 ` [PATCH 11/11] target, vhost-scsi: don't switch cpus on completion Mike Christie
2021-02-08 10:48 ` [PATCH 00/11] target: fix cmd plugging and completion Stefan Hajnoczi
2021-02-08 10:48   ` Stefan Hajnoczi
2021-02-08 12:01 ` Michael S. Tsirkin
2021-02-08 12:01   ` Michael S. Tsirkin

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=20210204113513.93204-2-michael.christie@oracle.com \
    --to=michael.christie@oracle.com \
    --cc=jasowang@redhat.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=mst@redhat.com \
    --cc=stefanha@redhat.com \
    --cc=target-devel@vger.kernel.org \
    --cc=virtualization@lists.linux-foundation.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.