public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] block: fix request.queuelist usage in flush
@ 2024-06-04  6:47 Chengming Zhou
  2024-06-04 14:17 ` Jens Axboe
  2024-06-05  8:45 ` Friedrich Weber
  0 siblings, 2 replies; 16+ messages in thread
From: Chengming Zhou @ 2024-06-04  6:47 UTC (permalink / raw)
  To: axboe, ming.lei, hch, f.weber, bvanassche
  Cc: linux-block, linux-kernel, chengming.zhou, zhouchengming

Friedrich Weber reported a kernel crash problem and bisected to commit
81ada09cc25e ("blk-flush: reuse rq queuelist in flush state machine").

The root cause is that we use "list_move_tail(&rq->queuelist, pending)"
in the PREFLUSH/POSTFLUSH sequences. But rq->queuelist.next == xxx since
it's popped out from plug->cached_rq in __blk_mq_alloc_requests_batch().
We don't initialize its queuelist just for this first request, although
the queuelist of all later popped requests will be initialized.

Fix it by changing to use "list_add_tail(&rq->queuelist, pending)" so
rq->queuelist doesn't need to be initialized. It should be ok since rq
can't be on any list when PREFLUSH or POSTFLUSH, has no move actually.

Please note the commit 81ada09cc25e ("blk-flush: reuse rq queuelist in
flush state machine") also has another requirement that no drivers would
touch rq->queuelist after blk_mq_end_request() since we will reuse it to
add rq to the post-flush pending list in POSTFLUSH. If this is not true,
we will have to revert that commit IMHO.

Reported-by: Friedrich Weber <f.weber@proxmox.com>
Closes: https://lore.kernel.org/lkml/14b89dfb-505c-49f7-aebb-01c54451db40@proxmox.com/
Fixes: 81ada09cc25e ("blk-flush: reuse rq queuelist in flush state machine")
Cc: Christoph Hellwig <hch@lst.de>
Cc: ming.lei@redhat.com
Cc: bvanassche@acm.org
Signed-off-by: Chengming Zhou <chengming.zhou@linux.dev>
---
 block/blk-flush.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/blk-flush.c b/block/blk-flush.c
index c17cf8ed8113..e7aebcf00714 100644
--- a/block/blk-flush.c
+++ b/block/blk-flush.c
@@ -185,7 +185,7 @@ static void blk_flush_complete_seq(struct request *rq,
 		/* queue for flush */
 		if (list_empty(pending))
 			fq->flush_pending_since = jiffies;
-		list_move_tail(&rq->queuelist, pending);
+		list_add_tail(&rq->queuelist, pending);
 		break;
 
 	case REQ_FSEQ_DATA:
-- 
2.20.1


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

end of thread, other threads:[~2024-06-07 15:14 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-04  6:47 [PATCH] block: fix request.queuelist usage in flush Chengming Zhou
2024-06-04 14:17 ` Jens Axboe
2024-06-05 18:14   ` Jens Axboe
2024-06-05  8:45 ` Friedrich Weber
2024-06-05 10:30   ` Chengming Zhou
2024-06-05 10:54     ` Friedrich Weber
2024-06-05 13:34       ` Friedrich Weber
2024-06-05 14:27         ` Chengming Zhou
2024-06-06  8:44           ` Friedrich Weber
2024-06-06 16:05             ` Friedrich Weber
2024-06-07  2:37             ` Chengming Zhou
2024-06-07  4:55               ` Christoph Hellwig
2024-06-07  6:24                 ` Chengming Zhou
2024-06-07  6:31                   ` Christoph Hellwig
2024-06-07  6:33                     ` Chengming Zhou
2024-06-07 15:13               ` Friedrich Weber

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox