Skip to content

Commit 681cc5e

Browse files
committed
dm: fix request-based DM to not bounce through indirect dm_submit_bio
It is unnecessary to force request-based DM to call into bio-based dm_submit_bio (via indirect disk->fops->submit_bio) only to have it then call blk_mq_submit_bio(). Fix this by establishing a request-based DM block_device_operations (dm_rq_blk_dops, which doesn't have .submit_bio) and update dm_setup_md_queue() to set md->disk->fops to it for DM_TYPE_REQUEST_BASED. Remove DM_TYPE_REQUEST_BASED conditional in dm_submit_bio and unexport blk_mq_submit_bio. Fixes: c62b37d ("block: move ->make_request_fn to struct block_device_operations") Signed-off-by: Mike Snitzer <[email protected]>
1 parent 9c37de2 commit 681cc5e

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

block/blk-mq.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2265,7 +2265,6 @@ blk_qc_t blk_mq_submit_bio(struct bio *bio)
22652265
blk_queue_exit(q);
22662266
return BLK_QC_T_NONE;
22672267
}
2268-
EXPORT_SYMBOL_GPL(blk_mq_submit_bio); /* only for request based dm */
22692268

22702269
void blk_mq_free_rqs(struct blk_mq_tag_set *set, struct blk_mq_tags *tags,
22712270
unsigned int hctx_idx)

drivers/md/dm.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1633,18 +1633,6 @@ static blk_qc_t dm_submit_bio(struct bio *bio)
16331633
int srcu_idx;
16341634
struct dm_table *map;
16351635

1636-
if (dm_get_md_type(md) == DM_TYPE_REQUEST_BASED) {
1637-
/*
1638-
* We are called with a live reference on q_usage_counter, but
1639-
* that one will be released as soon as we return. Grab an
1640-
* extra one as blk_mq_submit_bio expects to be able to consume
1641-
* a reference (which lives until the request is freed in case a
1642-
* request is allocated).
1643-
*/
1644-
percpu_ref_get(&bio->bi_disk->queue->q_usage_counter);
1645-
return blk_mq_submit_bio(bio);
1646-
}
1647-
16481636
map = dm_get_live_table(md, &srcu_idx);
16491637
if (unlikely(!map)) {
16501638
DMERR_LIMIT("%s: mapping table unavailable, erroring io",
@@ -1727,6 +1715,7 @@ static int next_free_minor(int *minor)
17271715
}
17281716

17291717
static const struct block_device_operations dm_blk_dops;
1718+
static const struct block_device_operations dm_rq_blk_dops;
17301719
static const struct dax_operations dm_dax_ops;
17311720

17321721
static void dm_wq_work(struct work_struct *work);
@@ -2113,9 +2102,10 @@ int dm_setup_md_queue(struct mapped_device *md, struct dm_table *t)
21132102

21142103
switch (type) {
21152104
case DM_TYPE_REQUEST_BASED:
2105+
md->disk->fops = &dm_rq_blk_dops;
21162106
r = dm_mq_init_request_queue(md, t);
21172107
if (r) {
2118-
DMERR("Cannot initialize queue for request-based dm-mq mapped device");
2108+
DMERR("Cannot initialize queue for request-based dm mapped device");
21192109
return r;
21202110
}
21212111
break;
@@ -3095,6 +3085,15 @@ static const struct block_device_operations dm_blk_dops = {
30953085
.owner = THIS_MODULE
30963086
};
30973087

3088+
static const struct block_device_operations dm_rq_blk_dops = {
3089+
.open = dm_blk_open,
3090+
.release = dm_blk_close,
3091+
.ioctl = dm_blk_ioctl,
3092+
.getgeo = dm_blk_getgeo,
3093+
.pr_ops = &dm_pr_ops,
3094+
.owner = THIS_MODULE
3095+
};
3096+
30983097
static const struct dax_operations dm_dax_ops = {
30993098
.direct_access = dm_dax_direct_access,
31003099
.dax_supported = dm_dax_supported,

0 commit comments

Comments
 (0)