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 04/11] tcm loop: use lio wq cmd submission helper
Date: Thu,  4 Feb 2021 05:35:06 -0600	[thread overview]
Message-ID: <20210204113513.93204-5-michael.christie@oracle.com> (raw)
In-Reply-To: <20210204113513.93204-1-michael.christie@oracle.com>

Convert loop to use the lio wq cmd submission helper.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
---
 drivers/target/loopback/tcm_loop.c | 25 +++++++++++--------------
 drivers/target/loopback/tcm_loop.h |  1 -
 2 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c
index 274826a2b0bd..8dc45165d33b 100644
--- a/drivers/target/loopback/tcm_loop.c
+++ b/drivers/target/loopback/tcm_loop.c
@@ -39,7 +39,6 @@
 
 #define to_tcm_loop_hba(hba)	container_of(hba, struct tcm_loop_hba, dev)
 
-static struct workqueue_struct *tcm_loop_workqueue;
 static struct kmem_cache *tcm_loop_cmd_cache;
 
 static int tcm_loop_hba_no_cnt;
@@ -106,11 +105,10 @@ static struct device_driver tcm_loop_driverfs = {
  */
 static struct device *tcm_loop_primary;
 
-static void tcm_loop_submission_work(struct work_struct *work)
+static void tcm_loop_submit_queued_cmd(struct se_cmd *se_cmd)
 {
 	struct tcm_loop_cmd *tl_cmd =
-		container_of(work, struct tcm_loop_cmd, work);
-	struct se_cmd *se_cmd = &tl_cmd->tl_se_cmd;
+		container_of(se_cmd, struct tcm_loop_cmd, tl_se_cmd);
 	struct scsi_cmnd *sc = tl_cmd->sc;
 	struct tcm_loop_nexus *tl_nexus;
 	struct tcm_loop_hba *tl_hba;
@@ -179,6 +177,11 @@ static void tcm_loop_submission_work(struct work_struct *work)
 static int tcm_loop_queuecommand(struct Scsi_Host *sh, struct scsi_cmnd *sc)
 {
 	struct tcm_loop_cmd *tl_cmd = scsi_cmd_priv(sc);
+	struct tcm_loop_hba *tl_hba;
+	struct tcm_loop_tpg *tl_tpg;
+
+	tl_hba = *(struct tcm_loop_hba **)shost_priv(sc->device->host);
+	tl_tpg = &tl_hba->tl_hba_tpgs[sc->device->id];
 
 	pr_debug("%s() %d:%d:%d:%llu got CDB: 0x%02x scsi_buf_len: %u\n",
 		 __func__, sc->device->host->host_no, sc->device->id,
@@ -188,8 +191,8 @@ static int tcm_loop_queuecommand(struct Scsi_Host *sh, struct scsi_cmnd *sc)
 	memset(tl_cmd, 0, sizeof(*tl_cmd));
 	tl_cmd->sc = sc;
 	tl_cmd->sc_cmd_tag = sc->request->tag;
-	INIT_WORK(&tl_cmd->work, tcm_loop_submission_work);
-	queue_work(tcm_loop_workqueue, &tl_cmd->work);
+
+	target_queue_cmd_submit(tl_tpg->tl_nexus->se_sess, &tl_cmd->tl_se_cmd);
 	return 0;
 }
 
@@ -1146,6 +1149,7 @@ static const struct target_core_fabric_ops loop_ops = {
 	.queue_status			= tcm_loop_queue_status,
 	.queue_tm_rsp			= tcm_loop_queue_tm_rsp,
 	.aborted_task			= tcm_loop_aborted_task,
+	.submit_queued_cmd		= tcm_loop_submit_queued_cmd,
 	.fabric_make_wwn		= tcm_loop_make_scsi_hba,
 	.fabric_drop_wwn		= tcm_loop_drop_scsi_hba,
 	.fabric_make_tpg		= tcm_loop_make_naa_tpg,
@@ -1161,17 +1165,13 @@ static int __init tcm_loop_fabric_init(void)
 {
 	int ret = -ENOMEM;
 
-	tcm_loop_workqueue = alloc_workqueue("tcm_loop", 0, 0);
-	if (!tcm_loop_workqueue)
-		goto out;
-
 	tcm_loop_cmd_cache = kmem_cache_create("tcm_loop_cmd_cache",
 				sizeof(struct tcm_loop_cmd),
 				__alignof__(struct tcm_loop_cmd),
 				0, NULL);
 	if (!tcm_loop_cmd_cache) {
 		pr_debug("kmem_cache_create() for tcm_loop_cmd_cache failed\n");
-		goto out_destroy_workqueue;
+		goto out;
 	}
 
 	ret = tcm_loop_alloc_core_bus();
@@ -1188,8 +1188,6 @@ static int __init tcm_loop_fabric_init(void)
 	tcm_loop_release_core_bus();
 out_destroy_cache:
 	kmem_cache_destroy(tcm_loop_cmd_cache);
-out_destroy_workqueue:
-	destroy_workqueue(tcm_loop_workqueue);
 out:
 	return ret;
 }
@@ -1199,7 +1197,6 @@ static void __exit tcm_loop_fabric_exit(void)
 	target_unregister_template(&loop_ops);
 	tcm_loop_release_core_bus();
 	kmem_cache_destroy(tcm_loop_cmd_cache);
-	destroy_workqueue(tcm_loop_workqueue);
 }
 
 MODULE_DESCRIPTION("TCM loopback virtual Linux/SCSI fabric module");
diff --git a/drivers/target/loopback/tcm_loop.h b/drivers/target/loopback/tcm_loop.h
index d3110909a213..437663b3905c 100644
--- a/drivers/target/loopback/tcm_loop.h
+++ b/drivers/target/loopback/tcm_loop.h
@@ -16,7 +16,6 @@ struct tcm_loop_cmd {
 	struct scsi_cmnd *sc;
 	/* The TCM I/O descriptor that is accessed via container_of() */
 	struct se_cmd tl_se_cmd;
-	struct work_struct work;
 	struct completion tmr_done;
 	/* Sense buffer that will be mapped into outgoing status */
 	unsigned char tl_sense_buf[TRANSPORT_SENSE_BUFFER];
-- 
2.25.1


  parent reply	other threads:[~2021-02-04 11:37 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 ` [PATCH 01/11] target: pass in fabric ops to session creation Mike Christie
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 ` Mike Christie [this message]
2021-02-04 11:35 ` [PATCH 05/11] vhost scsi: use lio wq cmd submission helper 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-5-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.