]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
bcache: fix set_at_max_writeback_rate() for multiple attached devices
authorColy Li <colyli@suse.de>
Mon, 19 Sep 2022 16:16:47 +0000 (00:16 +0800)
committerStefan Bader <stefan.bader@canonical.com>
Thu, 24 Nov 2022 13:25:04 +0000 (14:25 +0100)
commit3760b911fc61a188eaededcb1c784d08de94d6e0
treed893101331f76f0cdb4ce19d7d9c6bd12a300145
parentc36635bcc08e2789f4e94751b9ff79f7ef6b5eeb
bcache: fix set_at_max_writeback_rate() for multiple attached devices

BugLink: https://bugs.launchpad.net/bugs/1996825
[ Upstream commit d2d05b88035d2d51a5bb6c5afec88a0880c73df4 ]

Inside set_at_max_writeback_rate() the calculation in following if()
check is wrong,
if (atomic_inc_return(&c->idle_counter) <
    atomic_read(&c->attached_dev_nr) * 6)

Because each attached backing device has its own writeback thread
running and increasing c->idle_counter, the counter increates much
faster than expected. The correct calculation should be,
(counter / dev_nr) < dev_nr * 6
which equals to,
counter < dev_nr * dev_nr * 6

This patch fixes the above mistake with correct calculation, and helper
routine idle_counter_exceeded() is added to make code be more clear.

Reported-by: Mingzhe Zou <mingzhe.zou@easystack.cn>
Signed-off-by: Coly Li <colyli@suse.de>
Acked-by: Mingzhe Zou <mingzhe.zou@easystack.cn>
Link: https://lore.kernel.org/r/20220919161647.81238-6-colyli@suse.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/md/bcache/writeback.c