Linux kernel -stable discussions
 help / color / mirror / Atom feed
* [PATCH v5.10] block: don't call rq_qos_ops->done_bio if the bio isn't  tracked
@ 2025-07-29  5:09 Shivani Agarwal
  2025-07-29 19:37 ` Sasha Levin
  0 siblings, 1 reply; 2+ messages in thread
From: Shivani Agarwal @ 2025-07-29  5:09 UTC (permalink / raw)
  To: stable, gregkh
  Cc: bcm-kernel-feedback-list, linux-kernel, ajay.kaher,
	alexey.makhalov, tapas.kundu, axboe, linux-block, Ming Lei,
	Yu Kuai, tj, Christoph Hellwig, Sasha Levin, Shivani Agarwal

From: Ming Lei <ming.lei@redhat.com>

[ Upstream commit a647a524a46736786c95cdb553a070322ca096e3 ]

rq_qos framework is only applied on request based driver, so:

1) rq_qos_done_bio() needn't to be called for bio based driver

2) rq_qos_done_bio() needn't to be called for bio which isn't tracked,
such as bios ended from error handling code.

Especially in bio_endio():

1) request queue is referred via bio->bi_bdev->bd_disk->queue, which
may be gone since request queue refcount may not be held in above two
cases

2) q->rq_qos may be freed in blk_cleanup_queue() when calling into
__rq_qos_done_bio()

Fix the potential kernel panic by not calling rq_qos_ops->done_bio if
the bio isn't tracked. This way is safe because both ioc_rqos_done_bio()
and blkcg_iolatency_done_bio() are nop if the bio isn't tracked.

Reported-by: Yu Kuai <yukuai3@huawei.com>
Cc: tj@kernel.org
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Acked-by: Tejun Heo <tj@kernel.org>
Link: https://lore.kernel.org/r/20210924110704.1541818-1-ming.lei@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
[Shivani: Modified to apply on 5.10.y]
Signed-off-by: Shivani Agarwal <shivani.agarwal@broadcom.com>
---
 block/bio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/bio.c b/block/bio.c
index 88a09c31095f..7851f54edc76 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -1430,7 +1430,7 @@ void bio_endio(struct bio *bio)
 	if (!bio_integrity_endio(bio))
 		return;
 
-	if (bio->bi_disk)
+	if (bio->bi_disk && bio_flagged(bio, BIO_TRACKED))
 		rq_qos_done_bio(bio->bi_disk->queue, bio);
 
 	/*
-- 
2.40.4


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

* Re: [PATCH v5.10] block: don't call rq_qos_ops->done_bio if the bio isn't  tracked
  2025-07-29  5:09 [PATCH v5.10] block: don't call rq_qos_ops->done_bio if the bio isn't tracked Shivani Agarwal
@ 2025-07-29 19:37 ` Sasha Levin
  0 siblings, 0 replies; 2+ messages in thread
From: Sasha Levin @ 2025-07-29 19:37 UTC (permalink / raw)
  To: stable, shivani.agarwal; +Cc: Sasha Levin

[ Sasha's backport helper bot ]

Hi,

Summary of potential issues:
⚠️ Found follow-up fixes in mainline

The upstream commit SHA1 provided is correct: a647a524a46736786c95cdb553a070322ca096e3

WARNING: Author mismatch between patch and upstream commit:
Backport author: Shivani Agarwal <shivani.agarwal@broadcom.com>
Commit author: Ming Lei <ming.lei@redhat.com>

Status in newer kernel trees:
6.15.y | Present (exact SHA1)
6.12.y | Present (exact SHA1)
6.6.y | Present (exact SHA1)
6.1.y | Present (exact SHA1)
5.15.y | Present (exact SHA1)

Found fixes commits:
aa1b46dcdc7b block: fix rq-qos breakage from skipping rq_qos_done_bio()

Note: The patch differs from the upstream commit:
---
1:  a647a524a467 < -:  ------------ block: don't call rq_qos_ops->done_bio if the bio isn't tracked
-:  ------------ > 1:  2b3b2e94a12e block: don't call rq_qos_ops->done_bio if the bio isn't tracked

---

Results of testing on various branches:

| Branch                    | Patch Apply | Build Test |
|---------------------------|-------------|------------|
| origin/linux-5.10.y       | Success     | Success    |

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

end of thread, other threads:[~2025-07-29 19:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-29  5:09 [PATCH v5.10] block: don't call rq_qos_ops->done_bio if the bio isn't tracked Shivani Agarwal
2025-07-29 19:37 ` Sasha Levin

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