diff mbox series

[7/9] block: assign batch completion handler in blk_poll()

Message ID 20211013165416.985696-8-axboe@kernel.dk (mailing list archive)
State New, archived
Headers show
Series Batched completions | expand

Commit Message

Jens Axboe Oct. 13, 2021, 4:54 p.m. UTC
If an io_batch is passed in to blk_poll(), we need to assign the batch
handler associated with this queue. This allows callers to complete
an io_batch handler on by calling it.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 block/blk-mq.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

Comments

Christoph Hellwig Oct. 14, 2021, 7:48 a.m. UTC | #1
On Wed, Oct 13, 2021 at 10:54:14AM -0600, Jens Axboe wrote:
> If an io_batch is passed in to blk_poll(), we need to assign the batch
> handler associated with this queue. This allows callers to complete
> an io_batch handler on by calling it.

blk_poll() is gone now :)

> +	if (iob) {
> +		iob->complete = q->mq_ops->complete_batch;
> +		if (!iob->complete) {
> +			WARN_ON_ONCE(iob->req_list);
> +			iob = NULL;
> +		}
> +	}

Assigning first and checking later looks a little strange, even if it
makes no actual difference.  Why not:

	if (iob && q->mq_ops->complete_batch)
	 	iob->complete = q->mq_ops->complete_batch;
	else
		iob = NULL;

Also I'd expect this patch in the series right after the other block
patches.
Jens Axboe Oct. 14, 2021, 3:43 p.m. UTC | #2
On 10/14/21 1:48 AM, Christoph Hellwig wrote:
> On Wed, Oct 13, 2021 at 10:54:14AM -0600, Jens Axboe wrote:
>> If an io_batch is passed in to blk_poll(), we need to assign the batch
>> handler associated with this queue. This allows callers to complete
>> an io_batch handler on by calling it.
> 
> blk_poll() is gone now :)
> 
>> +	if (iob) {
>> +		iob->complete = q->mq_ops->complete_batch;
>> +		if (!iob->complete) {
>> +			WARN_ON_ONCE(iob->req_list);
>> +			iob = NULL;
>> +		}
>> +	}
> 
> Assigning first and checking later looks a little strange, even if it
> makes no actual difference.  Why not:
> 
> 	if (iob && q->mq_ops->complete_batch)
> 	 	iob->complete = q->mq_ops->complete_batch;
> 	else
> 		iob = NULL;

Done.

> Also I'd expect this patch in the series right after the other block
> patches.

Moved.
diff mbox series

Patch

diff --git a/block/blk-mq.c b/block/blk-mq.c
index d603703cf272..deafd444761d 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -4302,6 +4302,19 @@  static int blk_mq_poll_classic(struct request_queue *q, blk_qc_t cookie,
 
 	hctx->poll_considered++;
 
+	/*
+	 * If batching is requested but the target doesn't support batched
+	 * completions, then just clear ib and completions will be handled
+	 * normally.
+	 */
+	if (iob) {
+		iob->complete = q->mq_ops->complete_batch;
+		if (!iob->complete) {
+			WARN_ON_ONCE(iob->req_list);
+			iob = NULL;
+		}
+	}
+
 	do {
 		hctx->poll_invoked++;