From cef6f55a9fb4f6d6f9df0f772aa64cf159997466 Mon Sep 17 00:00:00 2001 From: Mike Snitzer Date: Thu, 11 Oct 2018 17:44:04 -0400 Subject: [PATCH] dm table: require that request-based DM be layered on blk-mq devices Now that request-based DM (multipath) is blk-mq only: this restriction is required while the legacy request-based IO path still exists. Signed-off-by: Mike Snitzer --- drivers/md/dm-table.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index eeea32b..618edfc 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -908,10 +908,21 @@ static bool dm_table_supports_dax(struct dm_table *t) static bool dm_table_does_not_support_partial_completion(struct dm_table *t); +struct verify_rq_based_data { + unsigned sq_count; + unsigned mq_count; +}; + static int device_is_rq_based(struct dm_target *ti, struct dm_dev *dev, sector_t start, sector_t len, void *data) { struct request_queue *q = bdev_get_queue(dev->bdev); + struct verify_rq_based_data *v = data; + + if (q->mq_ops) + v->mq_count++; + else + v->sq_count++; return queue_is_rq_based(q); } @@ -920,6 +931,7 @@ static int dm_table_determine_type(struct dm_table *t) { unsigned i; unsigned bio_based = 0, request_based = 0, hybrid = 0; + struct verify_rq_based_data v = {.sq_count = 0, .mq_count = 0}; struct dm_target *tgt; struct list_head *devices = dm_table_get_devices(t); enum dm_queue_mode live_md_type = dm_get_md_type(t->md); @@ -1022,10 +1034,14 @@ verify_rq_based: /* Non-request-stackable devices can't be used for request-based dm */ if (!tgt->type->iterate_devices || - !tgt->type->iterate_devices(tgt, device_is_rq_based, NULL)) { + !tgt->type->iterate_devices(tgt, device_is_rq_based, &v)) { DMERR("table load rejected: including non-request-stackable devices"); return -EINVAL; } + if (v.sq_count > 0) { + DMERR("table load rejected: not all devices are blk-mq request-stackable"); + return -EINVAL; + } return 0; } -- 2.7.4