]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commit
bcache: correct cache_dirty_target in __update_writeback_rate()
authorTang Junhui <tang.junhui@zte.com.cn>
Wed, 6 Sep 2017 06:25:56 +0000 (14:25 +0800)
committerSeth Forshee <seth.forshee@canonical.com>
Thu, 28 Sep 2017 14:36:14 +0000 (10:36 -0400)
commit3d62f3ac3d026c84e0a44caa85ff4c8aeaa9716e
treec6b46dd2ed637804965a5139e360a30b71b14f41
parentf6564858395cc1799c7a972f2f341a7961cd46f9
bcache: correct cache_dirty_target in __update_writeback_rate()

BugLink: http://bugs.launchpad.net/bugs/1720154
commit a8394090a9129b40f9d90dcb7f4a49d60c727ca6 upstream.

__update_write_rate() uses a Proportion-Differentiation Controller
algorithm to control writeback rate. A dirty target number is used in
this PD controller to control writeback rate. A larger target number
will make the writeback rate smaller, on the versus, a smaller target
number will make the writeback rate larger.

bcache uses the following steps to calculate the target number,
1) cache_sectors = all-buckets-of-cache-set * buckets-size
2) cache_dirty_target = cache_sectors * cached-device-writeback_percent
3) target = cache_dirty_target *
(sectors-of-cached-device/sectors-of-all-cached-devices-of-this-cache-set)

The calculation at step 1) for cache_sectors is incorrect, which does
not consider dirty blocks occupied by flash only volume.

A flash only volume can be took as a bcache device without cached
device. All data sectors allocated for it are persistent on cache device
and marked dirty, they are not touched by bcache writeback and garbage
collection code. So data blocks of flash only volume should be ignore
when calculating cache_sectors of cache set.

Current code does not subtract dirty sectors of flash only volume, which
results a larger target number from the above 3 steps. And in sequence
the cache device's writeback rate is smaller then a correct value,
writeback speed is slower on all cached devices.

This patch fixes the incorrect slower writeback rate by subtracting
dirty sectors of flash only volumes in __update_writeback_rate().

(Commit log composed by Coly Li to pass checkpatch.pl checking)

Signed-off-by: Tang Junhui <tang.junhui@zte.com.cn>
Reviewed-by: Coly Li <colyli@suse.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
drivers/md/bcache/writeback.c
drivers/md/bcache/writeback.h