All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Christie <michael.christie@oracle.com>
To: mst@redhat.com, stefanha@redhat.com, Chaitanya.Kulkarni@wdc.com,
	hch@lst.de, loberman@redhat.com, martin.petersen@oracle.com,
	linux-scsi@vger.kernel.org, target-devel@vger.kernel.org
Cc: Mike Christie <michael.christie@oracle.com>
Subject: [PATCH 21/25] target: fix backend plugging
Date: Fri, 12 Feb 2021 01:26:38 -0600	[thread overview]
Message-ID: <20210212072642.17520-22-michael.christie@oracle.com> (raw)
In-Reply-To: <20210212072642.17520-1-michael.christie@oracle.com>

target_core_iblock is plugging and unplugging on every command and this
is causing perf issues for drivers that prefer batched cmds. With the
last patches we can now take multiple cmds from a fabric driver queue
and then pass them down the backend drivers in a batch. This patch adds
this support by adding 2 callouts to the backend for plugging and
unplugging the device. The next 2 patches add support for iblock and
tcmu device plugging.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
---
 drivers/target/target_core_transport.c | 43 +++++++++++++++++++++++++-
 include/target/target_core_backend.h   |  2 ++
 include/target/target_core_base.h      |  4 +++
 3 files changed, 48 insertions(+), 1 deletion(-)

diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index d782d3a0f9d5..45bb5253461a 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -1796,10 +1796,42 @@ void target_submit_cmd(struct se_cmd *se_cmd, struct se_session *se_sess,
 }
 EXPORT_SYMBOL(target_submit_cmd);
 
+
+static struct se_dev_plug *target_plug_device(struct se_device *se_dev)
+{
+	struct se_dev_plug *se_plug;
+
+	if (!se_dev->transport->plug_device)
+		return NULL;
+
+	se_plug = se_dev->transport->plug_device(se_dev);
+	if (!se_plug)
+		return NULL;
+
+	se_plug->se_dev = se_dev;
+	/*
+	 * We have a ref to the lun at this point, but the cmds could
+	 * complete before we unplug, so grab a ref to the se_device so we
+	 * can call back into the backend.
+	 */
+	config_group_get(&se_dev->dev_group);
+	return se_plug;
+}
+
+static void target_unplug_device(struct se_dev_plug *se_plug)
+{
+	struct se_device *se_dev = se_plug->se_dev;
+
+	se_dev->transport->unplug_device(se_plug);
+	config_group_put(&se_dev->dev_group);
+}
+
 void target_queued_submit_work(struct work_struct *work)
 {
 	struct se_cmd_queue *sq = container_of(work, struct se_cmd_queue, work);
 	struct se_cmd *se_cmd, *next_cmd;
+	struct se_dev_plug *se_plug = NULL;
+	struct se_device *se_dev = NULL;
 	struct llist_node *cmd_list;
 
 	cmd_list = llist_del_all(&sq->cmd_list);
@@ -1808,8 +1840,17 @@ void target_queued_submit_work(struct work_struct *work)
 		return;
 
 	cmd_list = llist_reverse_order(cmd_list);
-	llist_for_each_entry_safe(se_cmd, next_cmd, cmd_list, se_cmd_list)
+	llist_for_each_entry_safe(se_cmd, next_cmd, cmd_list, se_cmd_list) {
+		if (!se_dev) {
+			se_dev = se_cmd->se_dev;
+			se_plug = target_plug_device(se_dev);
+		}
+
 		target_submit(se_cmd);
+	}
+
+	if (se_plug)
+		target_unplug_device(se_plug);
 }
 
 /**
diff --git a/include/target/target_core_backend.h b/include/target/target_core_backend.h
index 6336780d83a7..aa5f83e55501 100644
--- a/include/target/target_core_backend.h
+++ b/include/target/target_core_backend.h
@@ -34,6 +34,8 @@ struct target_backend_ops {
 	int (*configure_device)(struct se_device *);
 	void (*destroy_device)(struct se_device *);
 	void (*free_device)(struct se_device *device);
+	struct se_dev_plug *(*plug_device)(struct se_device *se_dev);
+	void (*unplug_device)(struct se_dev_plug *se_plug);
 
 	ssize_t (*set_configfs_dev_params)(struct se_device *,
 					   const char *, ssize_t);
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
index 5e6703ca102d..b8e0a3250bd0 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -769,6 +769,10 @@ struct se_cmd_queue {
 	struct work_struct	work;
 };
 
+struct se_dev_plug {
+	struct se_device	*se_dev;
+};
+
 struct se_device_queue {
 	struct list_head	state_list;
 	spinlock_t		lock;
-- 
2.25.1


  parent reply	other threads:[~2021-02-12  7:32 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-12  7:26 PATCH 00/25 V4] target: fix cmd plugging and submission Mike Christie
2021-02-12  7:26 ` [PATCH 01/25] target: move t_task_cdb initialization Mike Christie
2021-02-12 19:07   ` Himanshu Madhani
2021-02-12  7:26 ` [PATCH 02/25] target: drop kref_get_unless_zero in target_get_sess_cmd Mike Christie
2021-02-12 19:08   ` Himanshu Madhani
2021-02-12  7:26 ` [PATCH 03/25] target: rename transport_init_se_cmd Mike Christie
2021-02-12 19:08   ` Himanshu Madhani
2021-02-12  7:26 ` [PATCH 04/25] target: break up target_submit_cmd_map_sgls Mike Christie
2021-02-12 19:09   ` Himanshu Madhani
2021-02-12  7:26 ` [PATCH 05/25] srpt: Convert to new submission API Mike Christie
2021-02-12 19:36   ` Bart Van Assche
2021-02-12  7:26 ` [PATCH 06/25] ibmvscsi_tgt: " Mike Christie
2021-02-12  7:26 ` [PATCH 07/25] qla2xxx: " Mike Christie
2021-02-12 19:16   ` Himanshu Madhani
2021-02-12  7:26 ` [PATCH 08/25] tcm_loop: " Mike Christie
2021-02-12  7:26 ` [PATCH 09/25] sbp_target: " Mike Christie
2021-02-12  7:26 ` [PATCH 10/25] usb gadget: " Mike Christie
2021-02-12  7:26 ` [PATCH 11/25] vhost-scsi: " Mike Christie
2021-02-16  8:40   ` Christoph Hellwig
2021-02-12  7:26 ` [PATCH 12/25] xen-scsiback: " Mike Christie
2021-02-12  7:26 ` [PATCH 13/25] tcm_fc: " Mike Christie
2021-02-12  7:26 ` [PATCH 14/25] target: remove target_submit_cmd_map_sgls Mike Christie
2021-02-12 22:17   ` Mike Christie
2021-02-16  8:40     ` Christoph Hellwig
2021-02-12  7:26 ` [PATCH 15/25] target: add gfp_t arg to target_cmd_init_cdb Mike Christie
2021-02-16  8:40   ` Christoph Hellwig
2021-02-12  7:26 ` [PATCH 16/25] target: add workqueue based cmd submission Mike Christie
2021-02-12  7:26 ` [PATCH 17/25] vhost scsi: use lio wq cmd submission helper Mike Christie
2021-02-12  7:26 ` [PATCH 18/25] tcm loop: use blk cmd allocator for se_cmds Mike Christie
2021-02-12  7:26 ` [PATCH 19/25] tcm loop: use lio wq cmd submission helper Mike Christie
2021-02-12  7:26 ` [PATCH 20/25] target: cleanup cmd flag bits Mike Christie
2021-02-12 19:17   ` Himanshu Madhani
2021-02-16  8:41   ` Christoph Hellwig
2021-02-12  7:26 ` Mike Christie [this message]
2021-02-12  7:26 ` [PATCH 22/25] target iblock: add backend plug/unplug callouts Mike Christie
2021-02-12  7:26 ` [PATCH 23/25] target_core_user: " Mike Christie
2021-02-12  7:26 ` [PATCH 24/25] target: flush submission work during TMR processing Mike Christie
2021-02-12  7:26 ` [PATCH 25/25] target: make completion affinity configurable Mike Christie
2021-02-12 19:35   ` Himanshu Madhani
2021-02-15 16:32 ` PATCH 00/25 V4] target: fix cmd plugging and submission Laurence Oberman
2021-02-17 20:27 [PATCH 00/25 V5] " Mike Christie
2021-02-17 20:28 ` [PATCH 21/25] target: fix backend plugging Mike Christie
2021-02-19 19:40   ` Bodo Stroesser
2021-02-27 16:59 [PATCH 00/25 V5] target: fix cmd plugging and submission Mike Christie
2021-02-27 17:00 ` [PATCH 21/25] target: fix backend plugging Mike Christie

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=20210212072642.17520-22-michael.christie@oracle.com \
    --to=michael.christie@oracle.com \
    --cc=Chaitanya.Kulkarni@wdc.com \
    --cc=hch@lst.de \
    --cc=linux-scsi@vger.kernel.org \
    --cc=loberman@redhat.com \
    --cc=martin.petersen@oracle.com \
    --cc=mst@redhat.com \
    --cc=stefanha@redhat.com \
    --cc=target-devel@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.