Message ID | 20201223112624.78955-8-jefflexu@linux.alibaba.com (mailing list archive) |
---|---|
State | Changes Requested, archived |
Delegated to: | Mike Snitzer |
Headers | show |
Series | dm: add support of iopoll | expand |
On 12/23/20 7:26 PM, Jeffle Xu wrote: > Enable iopoll when all underlying target devices supports iopoll. > > Signed-off-by: Jeffle Xu <jefflexu@linux.alibaba.com> > --- > drivers/md/dm-table.c | 28 ++++++++++++++++++++++++++++ > drivers/md/dm.c | 1 + > 2 files changed, 29 insertions(+) > > diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c > index 188f41287f18..b0cd5bf58c3c 100644 > --- a/drivers/md/dm-table.c > +++ b/drivers/md/dm-table.c > @@ -1791,6 +1791,31 @@ static bool dm_table_requires_stable_pages(struct dm_table *t) > return false; > } > > +static int device_supports_poll(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); > + > + return q && test_bit(QUEUE_FLAG_POLL, &q->queue_flags); > +} > + > +static bool dm_table_supports_poll(struct dm_table *t) > +{ > + struct dm_target *ti; > + unsigned int i; > + > + /* Ensure that all targets support iopoll. */ > + for (i = 0; i < dm_table_get_num_targets(t); i++) { > + ti = dm_table_get_target(t, i); > + > + if (!ti->type->iterate_devices || > + !ti->type->iterate_devices(ti, device_supports_poll, NULL)) > + return false; > + } > + > + return true; > +} > + > void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q, > struct queue_limits *limits) > { > @@ -1883,6 +1908,9 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q, > #endif > > blk_queue_update_readahead(q); > + > + if (dm_table_supports_poll(t)) > + blk_queue_flag_set(QUEUE_FLAG_POLL, q); > } > This works in arbitrary bio-based DM stacking. Suppose the following device stack: dm0 dm1 nvme0 nvme1 dm 0 will check if dm1 has QUEUE_FLAG_POLL flag set. > unsigned int dm_table_get_num_targets(struct dm_table *t) > diff --git a/drivers/md/dm.c b/drivers/md/dm.c > index 03c2b867acaa..ffd2c5ead256 100644 > --- a/drivers/md/dm.c > +++ b/drivers/md/dm.c > @@ -3049,6 +3049,7 @@ static const struct pr_ops dm_pr_ops = { > }; > > static const struct block_device_operations dm_blk_dops = { > + .iopoll = blk_bio_poll, > .submit_bio = dm_submit_bio, > .open = dm_blk_open, > .release = dm_blk_close, >
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index 188f41287f18..b0cd5bf58c3c 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -1791,6 +1791,31 @@ static bool dm_table_requires_stable_pages(struct dm_table *t) return false; } +static int device_supports_poll(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); + + return q && test_bit(QUEUE_FLAG_POLL, &q->queue_flags); +} + +static bool dm_table_supports_poll(struct dm_table *t) +{ + struct dm_target *ti; + unsigned int i; + + /* Ensure that all targets support iopoll. */ + for (i = 0; i < dm_table_get_num_targets(t); i++) { + ti = dm_table_get_target(t, i); + + if (!ti->type->iterate_devices || + !ti->type->iterate_devices(ti, device_supports_poll, NULL)) + return false; + } + + return true; +} + void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q, struct queue_limits *limits) { @@ -1883,6 +1908,9 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q, #endif blk_queue_update_readahead(q); + + if (dm_table_supports_poll(t)) + blk_queue_flag_set(QUEUE_FLAG_POLL, q); } unsigned int dm_table_get_num_targets(struct dm_table *t) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 03c2b867acaa..ffd2c5ead256 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -3049,6 +3049,7 @@ static const struct pr_ops dm_pr_ops = { }; static const struct block_device_operations dm_blk_dops = { + .iopoll = blk_bio_poll, .submit_bio = dm_submit_bio, .open = dm_blk_open, .release = dm_blk_close,
Enable iopoll when all underlying target devices supports iopoll. Signed-off-by: Jeffle Xu <jefflexu@linux.alibaba.com> --- drivers/md/dm-table.c | 28 ++++++++++++++++++++++++++++ drivers/md/dm.c | 1 + 2 files changed, 29 insertions(+)