• Yu Kuai's avatar
    block, bfq: don't break merge chain in bfq_split_bfqq() · 42c306ed
    Yu Kuai authored
    Consider the following scenario:
    
        Process 1       Process 2       Process 3       Process 4
         (BIC1)          (BIC2)          (BIC3)          (BIC4)
          Λ               |               |                |
           \-------------\ \-------------\ \--------------\|
                          V               V                V
          bfqq1--------->bfqq2---------->bfqq3----------->bfqq4
    ref    0              1               2                4
    
    If Process 1 issue a new IO and bfqq2 is found, and then bfq_init_rq()
    decide to spilt bfqq2 by bfq_split_bfqq(). Howerver, procress reference
    of bfqq2 is 1 and bfq_split_bfqq() just clear the coop flag, which will
    break the merge chain.
    
    Expected result: caller will allocate a new bfqq for BIC1
    
        Process 1       Process 2       Process 3       Process 4
         (BIC1)          (BIC2)          (BIC3)          (BIC4)
                          |               |                |
                           \-------------\ \--------------\|
                                          V                V
          bfqq1--------->bfqq2---------->bfqq3----------->bfqq4
    ref    0              0               1                3
    
    Since the condition is only used for the last bfqq4 when the previous
    bfqq2 and bfqq3 are already splited. Fix the problem by checking if
    bfqq is the last one in the merge chain as well.
    
    Fixes: 36eca894 ("block, bfq: add Early Queue Merge (EQM)")
    Signed-off-by: default avatarYu Kuai <yukuai3@huawei.com>
    Link: https://lore.kernel.org/r/20240902130329.3787024-4-yukuai1@huaweicloud.comSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
    42c306ed
bfq-iosched.c 265 KB