BACKPORT: FROMGIT: block: BFQ: Add several invariant checks

If anything goes wrong with the counters that track the number of
requests, I/O locks up. Make such scenarios easier to debug by adding
invariant checks for the request counters. Additionally, check that
BFQ queues are empty before these are freed.

Cc: Jan Kara <jack@suse.cz>
Cc: Yu Kuai <yukuai3@huawei.com>
Change-Id: I566e972e4c9c5c3e8bb256e6be39f5bb6bec7256
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20230516223853.1385255-1-bvanassche@acm.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Bug: 275581839
(cherry picked from commit 3e49c1e4a6 https://git.kernel.dk/cgit/linux/)
[ bvanassche: backported to kernel v5.15 ]
Signed-off-by: Bart Van Assche <bvanassche@google.com>
This commit is contained in:
Bart Van Assche
2023-05-16 15:38:53 -07:00
committed by Bart Van Assche
parent 5db3a9fa14
commit c44534436f

View File

@@ -5197,6 +5197,10 @@ void bfq_put_queue(struct bfq_queue *bfqq)
if (bfqq->bfqd && bfqq->bfqd->last_completed_rq_bfqq == bfqq)
bfqq->bfqd->last_completed_rq_bfqq = NULL;
WARN_ON_ONCE(!list_empty(&bfqq->fifo));
WARN_ON_ONCE(!RB_EMPTY_ROOT(&bfqq->sort_list));
WARN_ON_ONCE(bfqq->dispatched);
kmem_cache_free(bfq_pool, bfqq);
bfqg_and_blkg_put(bfqg);
}
@@ -6896,6 +6900,8 @@ static void bfq_exit_queue(struct elevator_queue *e)
bfq_deactivate_bfqq(bfqd, bfqq, false, false);
spin_unlock_irq(&bfqd->lock);
WARN_ON_ONCE(bfqd->rq_in_driver);
hrtimer_cancel(&bfqd->idle_slice_timer);
/* release oom-queue reference to root group */