[dm-devel] [PATCH v3 09/11] dm: support IO polling for bio-based dm device
Mikulas Patocka
mpatocka at redhat.com
Fri Feb 19 14:17:12 UTC 2021
On Mon, 8 Feb 2021, Jeffle Xu wrote:
> diff --git a/drivers/md/dm.c b/drivers/md/dm.c
> index c2945c90745e..8423f1347bb8 100644
> --- a/drivers/md/dm.c
> +++ b/drivers/md/dm.c
> @@ -1657,6 +1657,68 @@ static blk_qc_t dm_submit_bio(struct bio *bio)
> return BLK_QC_T_NONE;
> }
>
> +static int dm_poll_one_md(struct mapped_device *md);
> +
> +static int dm_poll_one_dev(struct dm_target *ti, struct dm_dev *dev,
> + sector_t start, sector_t len, void *data)
> +{
> + int i, *count = data;
> + struct request_queue *q = bdev_get_queue(dev->bdev);
> + struct blk_mq_hw_ctx *hctx;
> +
> + if (queue_is_mq(q)) {
> + if (!percpu_ref_tryget(&q->q_usage_counter))
> + return 0;
> +
> + queue_for_each_poll_hw_ctx(q, hctx, i)
> + *count += blk_mq_poll_hctx(q, hctx);
> +
> + percpu_ref_put(&q->q_usage_counter);
> + } else
> + *count += dm_poll_one_md(dev->bdev->bd_disk->private_data);
This is fragile, because in the future there may be other bio-based
drivers that support polling. You should check that "q" is really a device
mapper device before calling dm_poll_one_md on it.
Mikulas
More information about the dm-devel
mailing list