mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-04-08 07:24:01 +00:00
blkcg: reassociate bios when make_request() is called recursively
When submitting a bio, multiple recursive calls to make_request() may
occur. This causes the initial associate done in blkcg_bio_issue_check()
to be incorrect and reference the prior request_queue. This introduces
a helper to do reassociation when make_request() is recursively called.
Fixes: a7b39b4e96
("blkcg: always associate a bio with a blkg")
Reported-by: Valdis Kletnieks <valdis.kletnieks@vt.edu>
Signed-off-by: Dennis Zhou <dennis@kernel.org>
Tested-by: Valdis Kletnieks <valdis.kletnieks@vt.edu>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
b2c3fa5467
commit
d459d853c2
3 changed files with 24 additions and 0 deletions
20
block/bio.c
20
block/bio.c
|
@ -2083,6 +2083,26 @@ int bio_associate_create_blkg(struct request_queue *q, struct bio *bio)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* bio_reassociate_blkg - reassociate a bio with a blkg from q
|
||||||
|
* @q: request_queue where bio is going
|
||||||
|
* @bio: target bio
|
||||||
|
*
|
||||||
|
* When submitting a bio, multiple recursive calls to make_request() may occur.
|
||||||
|
* This causes the initial associate done in blkcg_bio_issue_check() to be
|
||||||
|
* incorrect and reference the prior request_queue. This performs reassociation
|
||||||
|
* when this situation happens.
|
||||||
|
*/
|
||||||
|
int bio_reassociate_blkg(struct request_queue *q, struct bio *bio)
|
||||||
|
{
|
||||||
|
if (bio->bi_blkg) {
|
||||||
|
blkg_put(bio->bi_blkg);
|
||||||
|
bio->bi_blkg = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return bio_associate_create_blkg(q, bio);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* bio_disassociate_task - undo bio_associate_current()
|
* bio_disassociate_task - undo bio_associate_current()
|
||||||
* @bio: target bio
|
* @bio: target bio
|
||||||
|
|
|
@ -2433,6 +2433,7 @@ blk_qc_t generic_make_request(struct bio *bio)
|
||||||
if (q)
|
if (q)
|
||||||
blk_queue_exit(q);
|
blk_queue_exit(q);
|
||||||
q = bio->bi_disk->queue;
|
q = bio->bi_disk->queue;
|
||||||
|
bio_reassociate_blkg(q, bio);
|
||||||
flags = 0;
|
flags = 0;
|
||||||
if (bio->bi_opf & REQ_NOWAIT)
|
if (bio->bi_opf & REQ_NOWAIT)
|
||||||
flags = BLK_MQ_REQ_NOWAIT;
|
flags = BLK_MQ_REQ_NOWAIT;
|
||||||
|
|
|
@ -514,6 +514,7 @@ int bio_associate_blkg(struct bio *bio, struct blkcg_gq *blkg);
|
||||||
int bio_associate_blkg_from_css(struct bio *bio,
|
int bio_associate_blkg_from_css(struct bio *bio,
|
||||||
struct cgroup_subsys_state *css);
|
struct cgroup_subsys_state *css);
|
||||||
int bio_associate_create_blkg(struct request_queue *q, struct bio *bio);
|
int bio_associate_create_blkg(struct request_queue *q, struct bio *bio);
|
||||||
|
int bio_reassociate_blkg(struct request_queue *q, struct bio *bio);
|
||||||
void bio_disassociate_task(struct bio *bio);
|
void bio_disassociate_task(struct bio *bio);
|
||||||
void bio_clone_blkg_association(struct bio *dst, struct bio *src);
|
void bio_clone_blkg_association(struct bio *dst, struct bio *src);
|
||||||
#else /* CONFIG_BLK_CGROUP */
|
#else /* CONFIG_BLK_CGROUP */
|
||||||
|
@ -522,6 +523,8 @@ static inline int bio_associate_blkg_from_css(struct bio *bio,
|
||||||
{ return 0; }
|
{ return 0; }
|
||||||
static inline int bio_associate_create_blkg(struct request_queue *q,
|
static inline int bio_associate_create_blkg(struct request_queue *q,
|
||||||
struct bio *bio) { return 0; }
|
struct bio *bio) { return 0; }
|
||||||
|
static inline int bio_reassociate_blkg(struct request_queue *q, struct bio *bio)
|
||||||
|
{ return 0; }
|
||||||
static inline void bio_disassociate_task(struct bio *bio) { }
|
static inline void bio_disassociate_task(struct bio *bio) { }
|
||||||
static inline void bio_clone_blkg_association(struct bio *dst,
|
static inline void bio_clone_blkg_association(struct bio *dst,
|
||||||
struct bio *src) { }
|
struct bio *src) { }
|
||||||
|
|
Loading…
Add table
Reference in a new issue