Skip to content

Commit 15729ff

Browse files
Algodev-githubaxboe
authored andcommitted
Revert "Revert "block, bfq: honor already-setup queue merges""
A crash [1] happened to be triggered in conjunction with commit 2d52c58 ("block, bfq: honor already-setup queue merges"). The latter was then reverted by commit ebc69e8 ("Revert "block, bfq: honor already-setup queue merges""). Yet, the reverted commit was not the one introducing the bug. In fact, it actually triggered a UAF introduced by a different commit, and now fixed by commit d29bd41 ("block, bfq: reset last_bfqq_created on group change"). So, there is no point in keeping commit 2d52c58 ("block, bfq: honor already-setup queue merges") out. This commit restores it. [1] https://bugzilla.kernel.org/show_bug.cgi?id=214503 Reported-by: Holger Hoffstätte <holger@applied-asynchrony.com> Signed-off-by: Paolo Valente <paolo.valente@linaro.org> Link: https://lore.kernel.org/r/20211125181510.15004-1-paolo.valente@linaro.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 9793961 commit 15729ff

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

block/bfq-iosched.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2782,6 +2782,15 @@ bfq_setup_merge(struct bfq_queue *bfqq, struct bfq_queue *new_bfqq)
27822782
* are likely to increase the throughput.
27832783
*/
27842784
bfqq->new_bfqq = new_bfqq;
2785+
/*
2786+
* The above assignment schedules the following redirections:
2787+
* each time some I/O for bfqq arrives, the process that
2788+
* generated that I/O is disassociated from bfqq and
2789+
* associated with new_bfqq. Here we increases new_bfqq->ref
2790+
* in advance, adding the number of processes that are
2791+
* expected to be associated with new_bfqq as they happen to
2792+
* issue I/O.
2793+
*/
27852794
new_bfqq->ref += process_refs;
27862795
return new_bfqq;
27872796
}
@@ -2844,6 +2853,10 @@ bfq_setup_cooperator(struct bfq_data *bfqd, struct bfq_queue *bfqq,
28442853
{
28452854
struct bfq_queue *in_service_bfqq, *new_bfqq;
28462855

2856+
/* if a merge has already been setup, then proceed with that first */
2857+
if (bfqq->new_bfqq)
2858+
return bfqq->new_bfqq;
2859+
28472860
/*
28482861
* Check delayed stable merge for rotational or non-queueing
28492862
* devs. For this branch to be executed, bfqq must not be
@@ -2945,9 +2958,6 @@ bfq_setup_cooperator(struct bfq_data *bfqd, struct bfq_queue *bfqq,
29452958
if (bfq_too_late_for_merging(bfqq))
29462959
return NULL;
29472960

2948-
if (bfqq->new_bfqq)
2949-
return bfqq->new_bfqq;
2950-
29512961
if (!io_struct || unlikely(bfqq == &bfqd->oom_bfqq))
29522962
return NULL;
29532963

0 commit comments

Comments
 (0)