From: Bart Van Assche <bart.vanassche@sandisk.com>
To: Mike Snitzer <snitzer@redhat.com>
Cc: device-mapper development <dm-devel@redhat.com>
Subject: [PATCH 2/7] dm: Simplify dm_table_determine_type()
Date: Tue, 15 Nov 2016 15:33:16 -0800 [thread overview]
Message-ID: <4b4da27f-1540-db69-dce7-431b61b164ef@sandisk.com> (raw)
In-Reply-To: <e83f8718-9e73-5544-3bcc-4d9851b90ba1@sandisk.com>
Use a single loop instead of two loops to determine whether or not
all_blk_mq has to be set.
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
---
drivers/md/dm-table.c | 25 ++++++++++++-------------
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 49893fdc..fff4979 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -871,7 +871,7 @@ static int dm_table_determine_type(struct dm_table *t)
{
unsigned i;
unsigned bio_based = 0, request_based = 0, hybrid = 0;
- bool verify_blk_mq = false;
+ unsigned sq_count = 0, mq_count = 0;
struct dm_target *tgt;
struct dm_dev_internal *dd;
struct list_head *devices = dm_table_get_devices(t);
@@ -959,20 +959,15 @@ static int dm_table_determine_type(struct dm_table *t)
}
if (q->mq_ops)
- verify_blk_mq = true;
+ mq_count++;
+ else
+ sq_count++;
}
-
- if (verify_blk_mq) {
- /* verify _all_ devices in the table are blk-mq devices */
- list_for_each_entry(dd, devices, list)
- if (!bdev_get_queue(dd->dm_dev->bdev)->mq_ops) {
- DMERR("table load rejected: not all devices"
- " are blk-mq request-stackable");
- return -EINVAL;
- }
-
- t->all_blk_mq = true;
+ if (sq_count && mq_count) {
+ DMERR("table load rejected: not all devices are blk-mq request-stackable");
+ return -EINVAL;
}
+ t->all_blk_mq = mq_count > 0;
return 0;
}
@@ -1021,6 +1016,10 @@ bool dm_table_request_based(struct dm_table *t)
return __table_type_request_based(dm_table_get_type(t));
}
+/*
+ * Returns true if all paths are blk-mq devices. Returns false if all paths
+ * are single queue block devices or if there are no paths.
+ */
bool dm_table_all_blk_mq_devices(struct dm_table *t)
{
return t->all_blk_mq;
--
2.10.1
next prev parent reply other threads:[~2016-11-15 23:33 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-15 23:31 [PATCH 0/7] dm-mpath: Fix a race condition in the blk-mq path Bart Van Assche
2016-11-15 23:32 ` [PATCH 1/7] dm: Fix a (theoretical?) race condition in rq_completed() Bart Van Assche
2016-11-16 0:46 ` Mike Snitzer
2016-11-15 23:33 ` Bart Van Assche [this message]
2016-11-16 14:54 ` [PATCH 2/7] dm: Simplify dm_table_determine_type() Mike Snitzer
2016-11-16 20:14 ` Bart Van Assche
2016-11-16 21:11 ` Mike Snitzer
2016-11-16 21:53 ` Bart Van Assche
2016-11-16 23:09 ` Mike Snitzer
2016-11-15 23:33 ` [PATCH 3/7] dm-mpath: Document a locking assumption Bart Van Assche
2016-11-18 0:07 ` Mike Snitzer
2016-11-15 23:34 ` [PATCH 4/7] dm-mpath: Change return type of pg_init_all_paths() from int into void Bart Van Assche
2016-11-15 23:34 ` [PATCH 5/7] dm-mpath: Do not touch *__clone if request allocation fails Bart Van Assche
2016-11-15 23:34 ` [PATCH 6/7] dm-mpath: Avoid code duplication in __multipath_map() Bart Van Assche
2016-11-16 0:39 ` Mike Snitzer
2016-11-15 23:35 ` [PATCH 7/7] dm-mpath: Fix a race condition " Bart Van Assche
2016-11-16 0:37 ` Mike Snitzer
2016-11-16 0:40 ` Bart Van Assche
2016-11-16 1:01 ` Mike Snitzer
2016-11-16 1:08 ` Bart Van Assche
2016-11-16 1:50 ` Mike Snitzer
2016-11-21 21:44 ` Bart Van Assche
2016-11-21 23:43 ` Mike Snitzer
2016-11-21 23:57 ` Bart Van Assche
2016-11-22 0:34 ` Mike Snitzer
2016-11-22 23:47 ` Bart Van Assche
2016-11-23 0:48 ` Mike Snitzer
2016-11-23 3:16 ` Mike Snitzer
2016-11-23 18:28 ` Bart Van Assche
2016-11-23 18:50 ` Mike Snitzer
2016-11-16 0:47 ` [PATCH 0/7] dm-mpath: Fix a race condition in the blk-mq path Mike Snitzer
2016-11-16 0:57 ` Bart Van Assche
2016-11-16 1:08 ` Mike Snitzer
2016-11-16 1:10 ` Bart Van Assche
2016-11-16 1:53 ` Mike Snitzer
2016-11-16 7:39 ` Hannes Reinecke
2016-11-16 14:56 ` Mike Snitzer
2016-11-16 18:22 ` Bart Van Assche
2016-11-16 19:32 ` Mike Snitzer
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=4b4da27f-1540-db69-dce7-431b61b164ef@sandisk.com \
--to=bart.vanassche@sandisk.com \
--cc=dm-devel@redhat.com \
--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).