All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] blk-mq: Properly init requests from blk_mq_alloc_request_hctx()
@ 2022-10-26 10:35 John Garry
  2022-10-26 11:39 ` Ming Lei
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: John Garry @ 2022-10-26 10:35 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, linux-kernel, hch, ming.lei, bvanassche, John Garry

Function blk_mq_alloc_request_hctx() is missing zeroing/init of rq->bio,
biotail, __sector, and __data_len members, which blk_mq_alloc_request()
has, so duplicate what we do in blk_mq_alloc_request().

Fixes: 1f5bd336b9150 ("blk-mq: add blk_mq_alloc_request_hctx")
Signed-off-by: John Garry <john.garry@huawei.com>
---
Difference to v1:
- init rq members in blk_mq_alloc_request_hctx(), rather than
  blk_mq_rq_ctx_init() (Ming Lei)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 497c413bce80..a1b6afe43913 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -611,6 +611,7 @@ struct request *blk_mq_alloc_request_hctx(struct request_queue *q,
 		.nr_tags	= 1,
 	};
 	u64 alloc_time_ns = 0;
+	struct request *rq;
 	unsigned int cpu;
 	unsigned int tag;
 	int ret;
@@ -660,8 +661,12 @@ struct request *blk_mq_alloc_request_hctx(struct request_queue *q,
 	tag = blk_mq_get_tag(&data);
 	if (tag == BLK_MQ_NO_TAG)
 		goto out_queue_exit;
-	return blk_mq_rq_ctx_init(&data, blk_mq_tags_from_data(&data), tag,
+	rq = blk_mq_rq_ctx_init(&data, blk_mq_tags_from_data(&data), tag,
 					alloc_time_ns);
+	rq->__data_len = 0;
+	rq->__sector = (sector_t) -1;
+	rq->bio = rq->biotail = NULL;
+	return rq;
 
 out_queue_exit:
 	blk_queue_exit(q);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] blk-mq: Properly init requests from blk_mq_alloc_request_hctx()
  2022-10-26 10:35 [PATCH v2] blk-mq: Properly init requests from blk_mq_alloc_request_hctx() John Garry
@ 2022-10-26 11:39 ` Ming Lei
  2022-10-28  8:30 ` Christoph Hellwig
  2022-10-28 13:55 ` Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Ming Lei @ 2022-10-26 11:39 UTC (permalink / raw)
  To: John Garry; +Cc: axboe, linux-block, linux-kernel, hch, bvanassche

On Wed, Oct 26, 2022 at 6:04 PM John Garry <john.garry@huawei.com> wrote:
>
> Function blk_mq_alloc_request_hctx() is missing zeroing/init of rq->bio,
> biotail, __sector, and __data_len members, which blk_mq_alloc_request()
> has, so duplicate what we do in blk_mq_alloc_request().
>
> Fixes: 1f5bd336b9150 ("blk-mq: add blk_mq_alloc_request_hctx")
> Signed-off-by: John Garry <john.garry@huawei.com>

Reviewed-by: Ming Lei <ming.lei@redhat.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] blk-mq: Properly init requests from blk_mq_alloc_request_hctx()
  2022-10-26 10:35 [PATCH v2] blk-mq: Properly init requests from blk_mq_alloc_request_hctx() John Garry
  2022-10-26 11:39 ` Ming Lei
@ 2022-10-28  8:30 ` Christoph Hellwig
  2022-10-28 13:55 ` Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2022-10-28  8:30 UTC (permalink / raw)
  To: John Garry; +Cc: axboe, linux-block, linux-kernel, hch, ming.lei, bvanassche

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] blk-mq: Properly init requests from blk_mq_alloc_request_hctx()
  2022-10-26 10:35 [PATCH v2] blk-mq: Properly init requests from blk_mq_alloc_request_hctx() John Garry
  2022-10-26 11:39 ` Ming Lei
  2022-10-28  8:30 ` Christoph Hellwig
@ 2022-10-28 13:55 ` Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2022-10-28 13:55 UTC (permalink / raw)
  To: John Garry; +Cc: linux-block, ming.lei, bvanassche, linux-kernel, hch

On Wed, 26 Oct 2022 18:35:13 +0800, John Garry wrote:
> Function blk_mq_alloc_request_hctx() is missing zeroing/init of rq->bio,
> biotail, __sector, and __data_len members, which blk_mq_alloc_request()
> has, so duplicate what we do in blk_mq_alloc_request().
> 
> 

Applied, thanks!

[1/1] blk-mq: Properly init requests from blk_mq_alloc_request_hctx()
      commit: e3c5a78cdb6237bfb9641b63cccf366325229eec

Best regards,
-- 
Jens Axboe



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-10-28 13:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-26 10:35 [PATCH v2] blk-mq: Properly init requests from blk_mq_alloc_request_hctx() John Garry
2022-10-26 11:39 ` Ming Lei
2022-10-28  8:30 ` Christoph Hellwig
2022-10-28 13:55 ` Jens Axboe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.