Skip to content

Commit ecedd3d

Browse files
Algodev-githubaxboe
authored andcommitted
block, bfq: get extra ref to prevent a queue from being freed during a group move
In bfq_bfqq_move(), the bfq_queue, say Q, to be moved to a new group may happen to be deactivated in the scheduling data structures of the source group (and then activated in the destination group). If Q is referred only by the data structures in the source group when the deactivation happens, then Q is freed upon the deactivation. This commit addresses this issue by getting an extra reference before the possible deactivation, and releasing this extra reference after Q has been moved. Tested-by: Chris Evich <[email protected]> Tested-by: Oleksandr Natalenko <[email protected]> Signed-off-by: Paolo Valente <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 32c59e3 commit ecedd3d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

block/bfq-cgroup.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,12 @@ void bfq_bfqq_move(struct bfq_data *bfqd, struct bfq_queue *bfqq,
651651
bfq_bfqq_expire(bfqd, bfqd->in_service_queue,
652652
false, BFQQE_PREEMPTED);
653653

654+
/*
655+
* get extra reference to prevent bfqq from being freed in
656+
* next possible deactivate
657+
*/
658+
bfqq->ref++;
659+
654660
if (bfq_bfqq_busy(bfqq))
655661
bfq_deactivate_bfqq(bfqd, bfqq, false, false);
656662
else if (entity->on_st)
@@ -670,6 +676,8 @@ void bfq_bfqq_move(struct bfq_data *bfqd, struct bfq_queue *bfqq,
670676

671677
if (!bfqd->in_service_queue && !bfqd->rq_in_driver)
672678
bfq_schedule_dispatch(bfqd);
679+
/* release extra ref taken above */
680+
bfq_put_queue(bfqq);
673681
}
674682

675683
/**

0 commit comments

Comments
 (0)