bcache: writeback: collapse contiguous IO better
Subsystems (2)
PATCH v2 1/1 bcache: writeback: collapse contiguous IO better
Previously, there was some logic that attempted to immediately issue writeback of backing-contiguous blocks when the writeback rate was fast.
The previous logic did not have any limits on the aggregate size it would issue, nor the number of keys it would combine at once. It would also discard the chance to do a contiguous write when the writeback rate was low-- e.g. at "background" writeback of target rate = 8, it would not combine two adjacent 4k writes and would instead seek the disk twice.
This patch imposes limits and explicitly understands the size of contiguous I/O during issue. It also will combine contiguous I/O in all circumstances, not just when writeback is requested to be relatively fast.
It is a win on its own, but also lays the groundwork for skip writes to short keys to make the I/O more sequential/contiguous. It also gets ready to start using blk_*_plug, and to allow issuing of non-contig I/O in parallel if requested by the user (to make use of disk throughput benefits available from higher queue depths).
This patch fixes a previous version where the contiguous information was not calculated properly, thanks to suggestions by Tang Junhui.
--- drivers/md/bcache/bcache.h | 6 --- drivers/md/bcache/writeback.c | 120 +++++++++++++++++++++++++++++------------- drivers/md/bcache/writeback.h | 3 ++ 3 files changed, 85 insertions(+), 44 deletions(-)
drivers/md/bcache/bcache.h +0 -6
@@ -323,12 +323,6 @@ struct cached_dev {struct bch_ratelimit writeback_rate;struct delayed_work writeback_rate_update; -/* -* Internal to the writeback code, so read_dirty() can keep track of -* where it's at. -*/ -sector_t last_read; -/* Limit number of writeback bios in flight */ struct semaphore in_flight;struct task_struct *writeback_thread;
drivers/md/bcache/writeback.c +82 -38
134 lines not on this page · raw message
drivers/md/bcache/writeback.h +3 -0
@@ -5,6 +5,9 @@#define CUTOFF_WRITEBACK 40#define CUTOFF_WRITEBACK_SYNC 70 +#define MAX_WRITEBACKS_IN_PASS 5 +#define MAX_WRITESIZE_IN_PASS 5000/* *512b */ +static inline uint64_t bcache_dev_sectors_dirty (struct bcache_device *d) {uint64_t i, ret =0 ;
Signature · 1 line
2.14.1