block-5.17-2022-03-10

-----BEGIN PGP SIGNATURE-----
 
 iQJEBAABCAAuFiEEwPw5LcreJtl1+l5K99NY+ylx4KYFAmIqYmQQHGF4Ym9lQGtl
 cm5lbC5kawAKCRD301j7KXHgpuXeD/sE0LlctQrdxzGXsn0v6EE1+l4LWcHEHd4Y
 doUaybspWHcjwcWLtYt5kHA/PljsNbMgZMw3PpWj7INvRwGOMW1EC2V2sKWVXKI7
 eZx59h2DjYmKz8uIWGuyvAlGLrc04Z3YENwSgPHX8m2aWKDjkgTeLsiMm4I5g3RM
 X74CDZWVZF7l40/IRs4E6i9mY0jQonZGo2tZIdaJOY+WMOg3tUVb+C9niBaxJxHD
 yjlCkuL2LpM0Wf7NXTbV7UFBny6i/e8QWhAPS2+78egyeVKL0Y0E0/ODsXLqgHED
 y1S+rJCJSAzwDTn+gfaJfEjn2Q1HcmZ/pyzLjZcDa3pfd0+V1POsQ2L3okAQLrmd
 UMCMdPmNMi2v5wW+sXrGmAlC4AGOUxU35jZMW5Ug2u2LXz3ivMFcf40Zog76JDI/
 xAx4y3z3UhV6MmE7Asd4r0ZTWb+tcZMb/2V2nr7EF67ZRG9C6jYs2kfiKkyBZ6Zl
 kUI9S5v/m7iZCk5txAKROUd7LklhD23CBUfYw/eq6OgjPRLPh1ElArOv7iBB3Nt2
 yntoLPtFF0OdeBF/YwCYPD/xdN4GsLhMxv5EV92IJtLYbcXgiS/dsKlE8EDvj/ZG
 qi/chyhM/MWxrqG9sJQhO5sYLBpiVYc8ZbZLFAvy2h+6n4dXulcp1jQO+QiXJ/bK
 gPrbTut+6A==
 =t7YQ
 -----END PGP SIGNATURE-----

Merge tag 'block-5.17-2022-03-10' of git://git.kernel.dk/linux-block

Pull block fix from Jens Axboe:
 "Just a single fix for a regression that occured in this merge window"

* tag 'block-5.17-2022-03-10' of git://git.kernel.dk/linux-block:
  block: fix blk_mq_attempt_bio_merge and rq_qos_throttle protection
This commit is contained in:
Linus Torvalds 2022-03-10 12:56:36 -08:00
commit 3bcb6451cc
1 changed files with 23 additions and 12 deletions

View File

@ -2718,7 +2718,8 @@ static bool blk_mq_attempt_bio_merge(struct request_queue *q,
static struct request *blk_mq_get_new_requests(struct request_queue *q,
struct blk_plug *plug,
struct bio *bio)
struct bio *bio,
unsigned int nsegs)
{
struct blk_mq_alloc_data data = {
.q = q,
@ -2730,6 +2731,11 @@ static struct request *blk_mq_get_new_requests(struct request_queue *q,
if (unlikely(bio_queue_enter(bio)))
return NULL;
if (blk_mq_attempt_bio_merge(q, bio, nsegs))
goto queue_exit;
rq_qos_throttle(q, bio);
if (plug) {
data.nr_tags = plug->nr_ios;
plug->nr_ios = 1;
@ -2742,12 +2748,13 @@ static struct request *blk_mq_get_new_requests(struct request_queue *q,
rq_qos_cleanup(q, bio);
if (bio->bi_opf & REQ_NOWAIT)
bio_wouldblock_error(bio);
queue_exit:
blk_queue_exit(q);
return NULL;
}
static inline struct request *blk_mq_get_cached_request(struct request_queue *q,
struct blk_plug *plug, struct bio *bio)
struct blk_plug *plug, struct bio **bio, unsigned int nsegs)
{
struct request *rq;
@ -2757,12 +2764,19 @@ static inline struct request *blk_mq_get_cached_request(struct request_queue *q,
if (!rq || rq->q != q)
return NULL;
if (blk_mq_get_hctx_type(bio->bi_opf) != rq->mq_hctx->type)
if (blk_mq_attempt_bio_merge(q, *bio, nsegs)) {
*bio = NULL;
return NULL;
if (op_is_flush(rq->cmd_flags) != op_is_flush(bio->bi_opf))
}
rq_qos_throttle(q, *bio);
if (blk_mq_get_hctx_type((*bio)->bi_opf) != rq->mq_hctx->type)
return NULL;
if (op_is_flush(rq->cmd_flags) != op_is_flush((*bio)->bi_opf))
return NULL;
rq->cmd_flags = bio->bi_opf;
rq->cmd_flags = (*bio)->bi_opf;
plug->cached_rq = rq_list_next(rq);
INIT_LIST_HEAD(&rq->queuelist);
return rq;
@ -2800,14 +2814,11 @@ void blk_mq_submit_bio(struct bio *bio)
if (!bio_integrity_prep(bio))
return;
if (blk_mq_attempt_bio_merge(q, bio, nr_segs))
return;
rq_qos_throttle(q, bio);
rq = blk_mq_get_cached_request(q, plug, bio);
rq = blk_mq_get_cached_request(q, plug, &bio, nr_segs);
if (!rq) {
rq = blk_mq_get_new_requests(q, plug, bio);
if (!bio)
return;
rq = blk_mq_get_new_requests(q, plug, bio, nr_segs);
if (unlikely(!rq))
return;
}