Commit 65803c20 authored by Mike Snitzer's avatar Mike Snitzer

dm table: train hybrid target type detection to select blk-mq if appropriate

Otherwise replacing the multipath target with the error target fails:
  device-mapper: ioctl: can't change device type after initial table load.

The error target was mistakenly considered to be target type
DM_TYPE_REQUEST_BASED rather than DM_TYPE_MQ_REQUEST_BASED even if the
target it was to replace was of type DM_TYPE_MQ_REQUEST_BASED.
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
parent e5863d9a
...@@ -831,7 +831,7 @@ static int dm_table_set_type(struct dm_table *t) ...@@ -831,7 +831,7 @@ static int dm_table_set_type(struct dm_table *t)
struct dm_target *tgt; struct dm_target *tgt;
struct dm_dev_internal *dd; struct dm_dev_internal *dd;
struct list_head *devices; struct list_head *devices;
unsigned live_md_type; unsigned live_md_type = dm_get_md_type(t->md);
for (i = 0; i < t->num_targets; i++) { for (i = 0; i < t->num_targets; i++) {
tgt = t->targets + i; tgt = t->targets + i;
...@@ -855,8 +855,8 @@ static int dm_table_set_type(struct dm_table *t) ...@@ -855,8 +855,8 @@ static int dm_table_set_type(struct dm_table *t)
* Determine the type from the live device. * Determine the type from the live device.
* Default to bio-based if device is new. * Default to bio-based if device is new.
*/ */
live_md_type = dm_get_md_type(t->md); if (live_md_type == DM_TYPE_REQUEST_BASED ||
if (live_md_type == DM_TYPE_REQUEST_BASED) live_md_type == DM_TYPE_MQ_REQUEST_BASED)
request_based = 1; request_based = 1;
else else
bio_based = 1; bio_based = 1;
...@@ -870,6 +870,17 @@ static int dm_table_set_type(struct dm_table *t) ...@@ -870,6 +870,17 @@ static int dm_table_set_type(struct dm_table *t)
BUG_ON(!request_based); /* No targets in this table */ BUG_ON(!request_based); /* No targets in this table */
/*
* Request-based dm supports only tables that have a single target now.
* To support multiple targets, request splitting support is needed,
* and that needs lots of changes in the block-layer.
* (e.g. request completion process for partial completion.)
*/
if (t->num_targets > 1) {
DMWARN("Request-based dm doesn't support multiple targets yet");
return -EINVAL;
}
/* Non-request-stackable devices can't be used for request-based dm */ /* Non-request-stackable devices can't be used for request-based dm */
devices = dm_table_get_devices(t); devices = dm_table_get_devices(t);
list_for_each_entry(dd, devices, list) { list_for_each_entry(dd, devices, list) {
...@@ -893,20 +904,14 @@ static int dm_table_set_type(struct dm_table *t) ...@@ -893,20 +904,14 @@ static int dm_table_set_type(struct dm_table *t)
" are blk-mq request-stackable"); " are blk-mq request-stackable");
return -EINVAL; return -EINVAL;
} }
} t->type = DM_TYPE_MQ_REQUEST_BASED;
/* } else if (hybrid && list_empty(devices) && live_md_type != DM_TYPE_NONE) {
* Request-based dm supports only tables that have a single target now. /* inherit live MD type */
* To support multiple targets, request splitting support is needed, t->type = live_md_type;
* and that needs lots of changes in the block-layer.
* (e.g. request completion process for partial completion.)
*/
if (t->num_targets > 1) {
DMWARN("Request-based dm doesn't support multiple targets yet");
return -EINVAL;
}
t->type = !use_blk_mq ? DM_TYPE_REQUEST_BASED : DM_TYPE_MQ_REQUEST_BASED; } else
t->type = DM_TYPE_REQUEST_BASED;
return 0; return 0;
} }
......
...@@ -101,7 +101,8 @@ int dm_setup_md_queue(struct mapped_device *md); ...@@ -101,7 +101,8 @@ int dm_setup_md_queue(struct mapped_device *md);
/* /*
* To check whether the target type is request-based or not (bio-based). * To check whether the target type is request-based or not (bio-based).
*/ */
#define dm_target_request_based(t) ((t)->type->map_rq != NULL) #define dm_target_request_based(t) (((t)->type->map_rq != NULL) || \
((t)->type->clone_and_map_rq != NULL))
/* /*
* To check whether the target type is a hybrid (capable of being * To check whether the target type is a hybrid (capable of being
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment