bcache patches for Linux v6.1
Subsystems (2)
cover bcache patches for Linux v6.1
Hi Jens,
This is the 1st wave bcache patches for Linux v6.1.
The patch from me fixes a calculation mistake reported by Mingzhe Zou, now the idle time to wait before setting maximum writeback rate can be increased when more backing devices attached.
And we also have other code cleanup patches from Jilin Yuan, Jules Maselbas, Lei Li and Lin Feng.
Please take them and thanks in advance.
Coly Li
---
Coly Li (1):
bcache: fix set_at_max_writeback_rate() for multiple attached devices
Jilin Yuan (1):
bcache:: fix repeated words in comments
Jules Maselbas (1):
bcache: bset: Fix comment typos
Li Lei (1):
bcache: remove unnecessary flush_workqueue
Lin Feng (1):
bcache: remove unused bch_mark_cache_readahead function def in stats.h
drivers/md/bcache/bcache.h | 2 +- drivers/md/bcache/bset.c | 2 +- drivers/md/bcache/stats.h | 1 - drivers/md/bcache/writeback.c | 78 ++++++++++++++++++++++++----------- 4 files changed, 56 insertions(+), 27 deletions(-)
Signature · 1 line
2.35.3
PATCH 1/5 bcache: remove unnecessary flush_workqueue
From: Li Lei <[email protected]>
All pending works will be drained by destroy_workqueue(), no need to call flush_workqueue() explicitly.
--- drivers/md/bcache/writeback.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/md/bcache/writeback.c +2 -3
@@ -801,10 +801,9 @@ static int bch_writeback_thread(void *arg) } } -if (dc->writeback_write_wq) { -flush_workqueue (dc->writeback_write_wq); +if (dc->writeback_write_wq)destroy_workqueue (dc->writeback_write_wq); - } +cached_dev_put (dc);wait_for_kthread_stop ();
Signature · 1 line
2.35.3
PATCH 2/5 bcache: remove unused bch_mark_cache_readahead function def in stats.h
In reply to Coly LiFrom: Lin Feng <[email protected]>
This is a cleanup for commit 1616a4c2ab1a ("bcache: remove bcache device self-defined readahead")', currently no user for bch_mark_cache_readahead() since that commit.
--- drivers/md/bcache/stats.h | 1 - 1 file changed, 1 deletion(-)
drivers/md/bcache/stats.h +0 -1
@@ -54,7 +54,6 @@ void bch_cache_accounting_destroy(struct cache_accounting *acc);void bch_mark_cache_accounting (struct cache_set *c,struct bcache_device *d,bool hit,bool bypass); -void bch_mark_cache_readahead (struct cache_set *c,struct bcache_device *d);void bch_mark_cache_miss_collision (struct cache_set *c,struct bcache_device *d); void bch_mark_sectors_bypassed(struct cache_set *c,
Signature · 1 line
2.35.3
PATCH 3/5 bcache: bset: Fix comment typos
In reply to Coly LiFrom: Jules Maselbas <[email protected]>
Remove the redundant word by, correct the typo creaated.
--- drivers/md/bcache/bset.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/bcache/bset.c +1 -1
@@ -1264,7 +1264,7 @@ static void __btree_sort(struct btree_keys *b, struct btree_iter *iter,* * Don't worry event 'out' is allocated from mempool, it can * still be swapped here. Because state->pool is a page mempool -* creaated by by mempool_init_page_pool(), which allocates +* created by mempool_init_page_pool(), which allocates * pages by alloc_pages() indeed. */
Signature · 1 line
2.35.3
PATCH 4/5 bcache:: fix repeated words in comments
In reply to Coly LiFrom: Jilin Yuan <[email protected]>
Delete the redundant word 'we'.
--- drivers/md/bcache/bcache.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/bcache/bcache.h +1 -1
@@ -107,7 +107,7 @@* * BTREE NODES: * -* Our unit of allocation is a bucket, and we we can't arbitrarily allocate and +* Our unit of allocation is a bucket, and we can't arbitrarily allocate and * free smaller than a bucket - so, that's how big our btree nodes are. * * (If buckets are really big we'll only use part of the bucket for a btree node
Signature · 1 line
2.35.3
PATCH 5/5 bcache: fix set_at_max_writeback_rate() for multiple attached devices
In reply to Coly LiInside 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.
--- drivers/md/bcache/writeback.c | 73 +++++++++++++++++++++++++---------- 1 file changed, 52 insertions(+), 21 deletions(-)
drivers/md/bcache/writeback.c +52 -21
@@ -157,6 +157,53 @@ static void __update_writeback_rate(struct cached_dev *dc) dc->writeback_rate_target = target; } +static bool idle_counter_exceeded (struct cache_set *c) +{ +int counter, dev_nr; + +/* +* If c->idle_counter is overflow (idel for really long time), +* reset as 0 and not set maximum rate this time for code +* simplicity. +*/ + counter =atomic_inc_return (&c->idle_counter); +if (counter <=0 ) { +atomic_set (&c->idle_counter,0 ); +return false; + } + + dev_nr =atomic_read (&c->attached_dev_nr); +if (dev_nr ==0 ) +return false; + +/* +* c->idle_counter is increased by writeback thread of all +* attached backing devices, in order to represent a rough +* time period, counter should be divided by dev_nr. +* Otherwise the idle time cannot be larger with more backing +* device attached. +* The following calculation equals to checking +* (counter / dev_nr) < (dev_nr * 6) +*/ +if (counter < (dev_nr * dev_nr *6 )) +return false; + +return true; +} + +/* +* Idle_counter is increased every time when update_writeback_rate() is +* called. If all backing devices attached to the same cache set have +* identical dc->writeback_rate_update_seconds values, it is about 6 +* rounds of update_writeback_rate() on each backing device before +* c->at_max_writeback_rate is set to 1, and then max wrteback rate set +* to each dc->writeback_rate.rate. +* In order to avoid extra locking cost for counting exact dirty cached +* devices number, c->attached_dev_nr is used to calculate the idle +* throushold. It might be bigger if not all cached device are in write- +* back mode, but it still works well with limited extra rounds of +* update_writeback_rate(). +*/ static bool set_at_max_writeback_rate (struct cache_set *c,struct cached_dev *dc) {
@@ -167,21 +214,8 @@ static bool set_at_max_writeback_rate(struct cache_set *c,/* Don't set max writeback rate if gc is running */ if (!c->gc_mark_valid)return false; -/* -* Idle_counter is increased everytime when update_writeback_rate() is -* called. If all backing devices attached to the same cache set have -* identical dc->writeback_rate_update_seconds values, it is about 6 -* rounds of update_writeback_rate() on each backing device before -* c->at_max_writeback_rate is set to 1, and then max wrteback rate set -* to each dc->writeback_rate.rate. -* In order to avoid extra locking cost for counting exact dirty cached -* devices number, c->attached_dev_nr is used to calculate the idle -* throushold. It might be bigger if not all cached device are in write- -* back mode, but it still works well with limited extra rounds of -* update_writeback_rate(). -*/ -if (atomic_inc_return (&c->idle_counter) < -atomic_read (&c->attached_dev_nr) *6 ) + +if (!idle_counter_exceeded (c))return false;if (atomic_read (&c->at_max_writeback_rate) !=1 )
@@ -195,13 +229,10 @@ static bool set_at_max_writeback_rate(struct cache_set *c, dc->writeback_rate_change =0 ;/* -* Check c->idle_counter and c->at_max_writeback_rate agagain in case -* new I/O arrives during before set_at_max_writeback_rate() returns. -* Then the writeback rate is set to 1, and its new value should be -* decided via __update_writeback_rate(). +* In case new I/O arrives during before +* set_at_max_writeback_rate() returns. */ -if ((atomic_read (&c->idle_counter) < -atomic_read (&c->attached_dev_nr) *6 ) || +if (!idle_counter_exceeded (c) || !atomic_read (&c->at_max_writeback_rate))return false;
Signature · 1 line
2.35.3
Quoted 10 lines · Coly Li
This is the 1st wave bcache patches for Linux v6.1.
The patch from me fixes a calculation mistake reported by Mingzhe Zou, now the idle time to wait before setting maximum writeback rate can be increased when more backing devices attached.
And we also have other code cleanup patches from Jilin Yuan, Jules Maselbas, Lei Li and Lin Feng.
[...]
Applied, thanks!
[1/5] bcache: remove unnecessary flush_workqueue
commit: 97d26ae764a43bfaf870312761a0a0f9b49b6351
[2/5] bcache: remove unused bch_mark_cache_readahead function def in stats.h
commit: d86b4e6dc88826f2b5cfa90c4ebbccb19a88bc39
[3/5] bcache: bset: Fix comment typos
commit: 11e529ccea33f24af6b54fe10bb3be9c1c48eddb
[4/5] bcache:: fix repeated words in comments
commit: 6dd3be6923eec2c49860e7292e4e2783c74a9dff
[5/5] bcache: fix set_at_max_writeback_rate() for multiple attached devices
commit: d2d05b88035d2d51a5bb6c5afec88a0880c73df4Best regards,
Signature · 1 line
Jens Axboe