linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ming Lei <ming.lei@redhat.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org,
	Jeffle Xu <jefflexu@linux.alibaba.com>,
	Mike Snitzer <snitzer@redhat.com>,
	dm-devel@redhat.com, Hannes Reinecke <hare@suse.de>
Subject: [PATCH V7 12/12] dm: support IO polling for bio-based dm device
Date: Fri, 23 Apr 2021 10:38:10 +0800	[thread overview]
Message-ID: <YIIzEmUV5GB5I13N@T590> (raw)
In-Reply-To: <20210422122038.2192933-13-ming.lei@redhat.com>

From 98a73d99c3c663a3cfaadfec2825d6d88289a102 Mon Sep 17 00:00:00 2001
From: Jeffle Xu <jefflexu@linux.alibaba.com>
Date: Mon, 8 Feb 2021 16:52:41 +0800
Subject: [PATCH V7 12/12] dm: support IO polling for bio-based dm device

IO polling is enabled when all underlying target devices are capable
of IO polling. The sanity check supports the stacked device model, in
which one dm device may be build upon another dm device. In this case,
the mapped device will check if the underlying dm target device
supports IO polling.

Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Jeffle Xu <jefflexu@linux.alibaba.com>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
V7:
	- don't export dm_table_supports_poll, as suggested by Jeffle

 drivers/md/dm-table.c | 24 ++++++++++++++++++++++++
 drivers/md/dm.c       |  2 ++
 2 files changed, 26 insertions(+)

diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 95391f78b8d5..0b3e34cbe241 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -1509,6 +1509,12 @@ struct dm_target *dm_table_find_target(struct dm_table *t, sector_t sector)
 	return &t->targets[(KEYS_PER_NODE * n) + k];
 }
 
+static int device_not_poll_capable(struct dm_target *ti, struct dm_dev *dev,
+				   sector_t start, sector_t len, void *data)
+{
+	return !blk_queue_poll(bdev_get_queue(dev->bdev));
+}
+
 /*
  * type->iterate_devices() should be called when the sanity check needs to
  * iterate and check all underlying data devices. iterate_devices() will
@@ -1559,6 +1565,11 @@ static int count_device(struct dm_target *ti, struct dm_dev *dev,
 	return 0;
 }
 
+static int dm_table_supports_poll(struct dm_table *t)
+{
+	return !dm_table_any_dev_attr(t, device_not_poll_capable, NULL);
+}
+
 /*
  * Check whether a table has no data devices attached using each
  * target's iterate_devices method.
@@ -2079,6 +2090,19 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
 
 	dm_update_keyslot_manager(q, t);
 	blk_queue_update_readahead(q);
+
+	/*
+	 * Check for request-based device is remained to
+	 * dm_mq_init_request_queue()->blk_mq_init_allocated_queue().
+	 * For bio-based device, only set QUEUE_FLAG_POLL when all underlying
+	 * devices supporting polling.
+	 */
+	if (__table_type_bio_based(t->type)) {
+		if (dm_table_supports_poll(t))
+			blk_queue_flag_set(QUEUE_FLAG_POLL, q);
+		else
+			blk_queue_flag_clear(QUEUE_FLAG_POLL, q);
+	}
 }
 
 unsigned int dm_table_get_num_targets(struct dm_table *t)
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 50b693d776d6..1b160e4e6446 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -2175,6 +2175,8 @@ int dm_setup_md_queue(struct mapped_device *md, struct dm_table *t)
 		}
 		break;
 	case DM_TYPE_BIO_BASED:
+		/* tell block layer we are capable of bio polling */
+		md->disk->flags |= GENHD_FL_CAP_BIO_POLL;
 	case DM_TYPE_DAX_BIO_BASED:
 		break;
 	case DM_TYPE_NONE:
-- 
2.29.2


  parent reply	other threads:[~2021-04-23  2:38 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-22 12:20 [PATCH V6 00/12] block: support bio based io polling Ming Lei
2021-04-22 12:20 ` [PATCH V6 01/12] block: add helper of blk_queue_poll Ming Lei
2021-04-22 12:20 ` [PATCH V6 02/12] block: define 'struct bvec_iter' as packed Ming Lei
2021-04-22 13:18   ` Hannes Reinecke
2021-04-22 12:20 ` [PATCH V6 03/12] block: add one helper to free io_context Ming Lei
2021-04-22 12:20 ` [PATCH V6 04/12] block: move block polling code into one dedicated source file Ming Lei
2021-04-22 13:19   ` Hannes Reinecke
2021-04-26  7:12   ` Hannes Reinecke
2021-04-22 12:20 ` [PATCH V6 05/12] block: extract one helper function polling hw queue Ming Lei
2021-04-22 12:20 ` [PATCH V6 06/12] block: prepare for supporting bio_list via other link Ming Lei
2021-04-22 12:20 ` [PATCH V6 07/12] block: create io poll context for submission and poll task Ming Lei
2021-04-22 12:20 ` [PATCH V6 08/12] block: add req flag of REQ_POLL_CTX Ming Lei
2021-04-22 12:20 ` [PATCH V6 09/12] block: use per-task poll context to implement bio based io polling Ming Lei
2021-04-26  7:17   ` Hannes Reinecke
2021-04-22 12:20 ` [PATCH V6 10/12] block: limit hw queues to be polled in each blk_poll() Ming Lei
2021-04-26  7:19   ` Hannes Reinecke
2021-04-26  8:00     ` Ming Lei
2021-04-26  9:05       ` Hannes Reinecke
2021-04-22 12:20 ` [PATCH V6 11/12] block: allow to control FLAG_POLL via sysfs for bio poll capable queue Ming Lei
2021-04-26  7:20   ` Hannes Reinecke
2021-04-22 12:20 ` [PATCH V6 12/12] dm: support IO polling for bio-based dm device Ming Lei
2021-04-23  1:32   ` JeffleXu
2021-04-23  2:39     ` Ming Lei
2021-04-23  2:38   ` Ming Lei [this message]
2021-05-17  6:16 ` [PATCH V6 00/12] block: support bio based io polling JeffleXu
2021-05-17  7:13   ` Ming Lei

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=YIIzEmUV5GB5I13N@T590 \
    --to=ming.lei@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=dm-devel@redhat.com \
    --cc=hare@suse.de \
    --cc=jefflexu@linux.alibaba.com \
    --cc=linux-block@vger.kernel.org \
    --cc=snitzer@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).