Skip to content

Commit 08d383a

Browse files
Algodev-githubaxboe
authored andcommitted
block, bfq: reset last_completed_rq_bfqq if the pointed queue is freed
Since commit 13a857a ("block, bfq: detect wakers and unconditionally inject their I/O"), BFQ stores, in a per-device pointer last_completed_rq_bfqq, the last bfq_queue that had an I/O request completed. If some bfq_queue receives new I/O right after the last request of last_completed_rq_bfqq has been completed, then last_completed_rq_bfqq may be a waker bfq_queue. But if the bfq_queue last_completed_rq_bfqq points to is freed, then last_completed_rq_bfqq becomes a dangling reference. This commit resets last_completed_rq_bfqq if the pointed bfq_queue is freed. Fixes: 13a857a ("block, bfq: detect wakers and unconditionally inject their I/O") Reported-by: Douglas Anderson <[email protected]> Tested-by: Douglas Anderson <[email protected]> Signed-off-by: Paolo Valente <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 430380b commit 08d383a

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

block/bfq-iosched.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1924,12 +1924,13 @@ static void bfq_add_request(struct request *rq)
19241924
* confirmed no later than during the next
19251925
* I/O-plugging interval for bfqq.
19261926
*/
1927-
if (!bfq_bfqq_has_short_ttime(bfqq) &&
1927+
if (bfqd->last_completed_rq_bfqq &&
1928+
!bfq_bfqq_has_short_ttime(bfqq) &&
19281929
ktime_get_ns() - bfqd->last_completion <
19291930
200 * NSEC_PER_USEC) {
19301931
if (bfqd->last_completed_rq_bfqq != bfqq &&
1931-
bfqd->last_completed_rq_bfqq !=
1932-
bfqq->waker_bfqq) {
1932+
bfqd->last_completed_rq_bfqq !=
1933+
bfqq->waker_bfqq) {
19331934
/*
19341935
* First synchronization detected with
19351936
* a candidate waker queue, or with a
@@ -4808,6 +4809,9 @@ void bfq_put_queue(struct bfq_queue *bfqq)
48084809
bfqq->bfqd->burst_size--;
48094810
}
48104811

4812+
if (bfqq->bfqd && bfqq->bfqd->last_completed_rq_bfqq == bfqq)
4813+
bfqq->bfqd->last_completed_rq_bfqq = NULL;
4814+
48114815
kmem_cache_free(bfq_pool, bfqq);
48124816
#ifdef CONFIG_BFQ_GROUP_IOSCHED
48134817
bfqg_and_blkg_put(bfqg);

0 commit comments

Comments
 (0)