Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dm: only initialize the request_queue once

Commit bfebd1cdb4 ("dm: add full blk-mq support to request-based DM")
didn't properly account for the need to short-circuit re-initializing
DM's blk-mq request_queue if it was already initialized.

Otherwise, reloading a blk-mq request-based DM table (either manually
or via multipathd) resulted in errors, see:
https://www.redhat.com/archives/dm-devel/2015-April/msg00132.html

Fix is to only initialize the request_queue on the initial table load
(when the mapped_device type is assigned).

This is better than having dm_init_request_based_blk_mq_queue() return
early if the queue was already initialized because it elevates the
constraint to a more meaningful location in DM core. As such the
pre-existing early return in dm_init_request_based_queue() can now be
removed.

Fixes: bfebd1cdb4 ("dm: add full blk-mq support to request-based DM")
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>

authored by

Christoph Hellwig and committed by
Mike Snitzer
3e6180f0 b787f68c

+9 -11
+9 -8
drivers/md/dm-ioctl.c
··· 1298 1298 goto err_unlock_md_type; 1299 1299 } 1300 1300 1301 - if (dm_get_md_type(md) == DM_TYPE_NONE) 1301 + if (dm_get_md_type(md) == DM_TYPE_NONE) { 1302 1302 /* Initial table load: acquire type of table. */ 1303 1303 dm_set_md_type(md, dm_table_get_type(t)); 1304 - else if (dm_get_md_type(md) != dm_table_get_type(t)) { 1304 + 1305 + /* setup md->queue to reflect md's type (may block) */ 1306 + r = dm_setup_md_queue(md); 1307 + if (r) { 1308 + DMWARN("unable to set up device queue for new table."); 1309 + goto err_unlock_md_type; 1310 + } 1311 + } else if (dm_get_md_type(md) != dm_table_get_type(t)) { 1305 1312 DMWARN("can't change device type after initial table load."); 1306 1313 r = -EINVAL; 1307 1314 goto err_unlock_md_type; 1308 1315 } 1309 1316 1310 - /* setup md->queue to reflect md's type (may block) */ 1311 - r = dm_setup_md_queue(md); 1312 - if (r) { 1313 - DMWARN("unable to set up device queue for new table."); 1314 - goto err_unlock_md_type; 1315 - } 1316 1317 dm_unlock_md_type(md); 1317 1318 1318 1319 /* stage inactive table */
-3
drivers/md/dm.c
··· 2662 2662 { 2663 2663 struct request_queue *q = NULL; 2664 2664 2665 - if (md->queue->elevator) 2666 - return 0; 2667 - 2668 2665 /* Fully initialize the queue */ 2669 2666 q = blk_init_allocated_queue(md->queue, dm_request_fn, NULL); 2670 2667 if (!q)