Skip to content

Commit 8ca719b

Browse files
bmarzinsMikulas Patocka
authored andcommitted
dm-table: fix checking for rq stackable devices
Due to the semantics of iterate_devices(), the current code allows a request-based dm table as long as it includes one request-stackable device. It is supposed to only allow tables where there are no non-request-stackable devices. Signed-off-by: Benjamin Marzinski <[email protected]> Reviewed-by: Mike Snitzer <[email protected]> Signed-off-by: Mikulas Patocka <[email protected]>
1 parent 86731a2 commit 8ca719b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

drivers/md/dm-table.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -899,17 +899,17 @@ static bool dm_table_supports_dax(struct dm_table *t,
899899
return true;
900900
}
901901

902-
static int device_is_rq_stackable(struct dm_target *ti, struct dm_dev *dev,
903-
sector_t start, sector_t len, void *data)
902+
static int device_is_not_rq_stackable(struct dm_target *ti, struct dm_dev *dev,
903+
sector_t start, sector_t len, void *data)
904904
{
905905
struct block_device *bdev = dev->bdev;
906906
struct request_queue *q = bdev_get_queue(bdev);
907907

908908
/* request-based cannot stack on partitions! */
909909
if (bdev_is_partition(bdev))
910-
return false;
910+
return true;
911911

912-
return queue_is_mq(q);
912+
return !queue_is_mq(q);
913913
}
914914

915915
static int dm_table_determine_type(struct dm_table *t)
@@ -1005,7 +1005,7 @@ static int dm_table_determine_type(struct dm_table *t)
10051005

10061006
/* Non-request-stackable devices can't be used for request-based dm */
10071007
if (!ti->type->iterate_devices ||
1008-
!ti->type->iterate_devices(ti, device_is_rq_stackable, NULL)) {
1008+
ti->type->iterate_devices(ti, device_is_not_rq_stackable, NULL)) {
10091009
DMERR("table load rejected: including non-request-stackable devices");
10101010
return -EINVAL;
10111011
}

0 commit comments

Comments
 (0)