Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: hch@lst.de (Christoph Hellwig)
Subject: [PATCH v2 1/6] block: introduce blk_execute_rq_polled
Date: Thu, 13 Dec 2018 09:24:44 +0100	[thread overview]
Message-ID: <20181213082444.GA869@lst.de> (raw)
In-Reply-To: <20181213063819.13614-2-sagi@grimberg.me>

On Wed, Dec 12, 2018@10:38:13PM -0800, Sagi Grimberg wrote:
> Used forsynchronous requests that needs polling. If we are knowingly
> sending a request down to a poll queue, we need a synchronous interface
> to poll for its completion.
> 
> Signed-off-by: Sagi Grimberg <sagi at grimberg.me>
> ---
>  block/blk-exec.c       | 29 +++++++++++++++++++++++++++++
>  block/blk-mq.c         |  8 --------
>  include/linux/blk-mq.h |  8 ++++++++
>  include/linux/blkdev.h |  2 ++
>  4 files changed, 39 insertions(+), 8 deletions(-)
> 
> diff --git a/block/blk-exec.c b/block/blk-exec.c
> index a34b7d918742..572032d60001 100644
> --- a/block/blk-exec.c
> +++ b/block/blk-exec.c
> @@ -90,3 +90,32 @@ void blk_execute_rq(struct request_queue *q, struct gendisk *bd_disk,
>  		wait_for_completion_io(&wait);
>  }
>  EXPORT_SYMBOL(blk_execute_rq);
> +
> +/**
> + * blk_execute_rq_polled - execute a request and poll for its completion
> + * @q:		queue to insert the request in
> + * @bd_disk:	matching gendisk
> + * @rq:		request to insert
> + * @at_head:    insert request at head or tail of queue
> + *
> + * Description:
> + *    Insert a fully prepared request at the back of the I/O scheduler queue
> + *    for execution and wait for completion.
> + */
> +void blk_execute_rq_polled(struct request_queue *q, struct gendisk *bd_disk,
> +		   struct request *rq, int at_head)
> +{
> +	DECLARE_COMPLETION_ONSTACK(wait);
> +
> +	WARN_ON_ONCE(!test_bit(QUEUE_FLAG_POLL, &q->queue_flags));
> +
> +	rq->cmd_flags |= REQ_HIPRI;
> +	rq->end_io_data = &wait;
> +	blk_execute_rq_nowait(q, bd_disk, rq, at_head, blk_end_sync_rq);
> +
> +	while (!completion_done(&wait)) {
> +		blk_poll(q, request_to_qc_t(rq->mq_hctx, rq), true);
> +		cond_resched();
> +	}

Can we just open code this in nvme for now?

> +static inline blk_qc_t request_to_qc_t(struct blk_mq_hw_ctx *hctx, struct request *rq)

Too long line.

> +{
> +	if (rq->tag != -1)
> +		return blk_tag_to_qc_t(rq->tag, hctx->queue_num, false);
> +
> +	return blk_tag_to_qc_t(rq->internal_tag, hctx->queue_num, true);
> +}

Also these are only two users of blk_tag_to_qc_t, it might be worth
to fold it into request_to_qc_t:

static inline blk_qc_t request_to_qc_t(struct blk_mq_hw_ctx *hctx,
		struct request *rq)
{
	if (rq->tag != -1)
		return rq->tag | (hctx->queue_num << BLK_QC_T_SHIFT);
	return rq->internal_tag | (hctx->queue_num << BLK_QC_T_SHIFT) |
			BLK_QC_T_INTERNAL;
}

  reply	other threads:[~2018-12-13  8:24 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-13  6:38 [PATCH v2 0/6] restore nvme-rdma polling Sagi Grimberg
2018-12-13  6:38 ` [PATCH v2 1/6] block: introduce blk_execute_rq_polled Sagi Grimberg
2018-12-13  8:24   ` Christoph Hellwig [this message]
2018-12-13 15:23   ` Steve Wise
2018-12-13  6:38 ` [PATCH v2 2/6] nvme-core: allow __nvme_submit_sync_cmd to poll Sagi Grimberg
2018-12-13  8:27   ` Christoph Hellwig
2018-12-13 15:19   ` Steve Wise
2018-12-13  6:38 ` [PATCH v2 3/6] nvme-fabrics: allow nvmf_connect_io_queue " Sagi Grimberg
2018-12-13  8:27   ` Christoph Hellwig
2018-12-13 15:25   ` Steve Wise
2018-12-13  6:38 ` [PATCH v2 4/6] nvme-fabrics: allow user to pass in nr_poll_queues Sagi Grimberg
2018-12-13 15:26   ` Steve Wise
2018-12-13  6:38 ` [PATCH v2 5/6] nvme-rdma: implement polling queue map Sagi Grimberg
2018-12-13 15:28   ` Steve Wise
2018-12-13  6:38 ` [PATCH v2 6/6] nvme-multipath: disable polling for underlying namespace request queue Sagi Grimberg
2018-12-13  8:31   ` Christoph Hellwig
2018-12-13 15:49     ` Sagi Grimberg
2018-12-13 15:52       ` Christoph Hellwig
2018-12-13 16:14         ` Sagi Grimberg
2018-12-13 20:13           ` Christoph Hellwig
2018-12-13 15:28   ` Steve Wise
2018-12-13  6:38 ` [PATCH v2 nvme-cli 7/6] fabrics: pass in number of polling queues Sagi Grimberg
2018-12-13 15:29   ` Steve Wise

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181213082444.GA869@lst.de \
    --to=hch@lst.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox