From: Coly Li <colyli@suse.de>
To: linux-bcache@vger.kernel.org, linux-block@vger.kernel.org,
axboe@kernel.dk
Cc: bcache@lists.ewheeler.net, Tang Junhui <tang.junhui@zte.com.cn>,
stable@vger.kernel.org
Subject: [PATCH 06/12] bcache: correct cache_dirty_target in __update_writeback_rate()
Date: Wed, 6 Sep 2017 14:25:56 +0800 [thread overview]
Message-ID: <20170906062602.50497-7-colyli@suse.de> (raw)
In-Reply-To: <20170906062602.50497-1-colyli@suse.de>
From: Tang Junhui <tang.junhui@zte.com.cn>
__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>
Cc: stable@vger.kernel.org
---
drivers/md/bcache/writeback.c | 3 ++-
drivers/md/bcache/writeback.h | 19 +++++++++++++++++++
2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/drivers/md/bcache/writeback.c b/drivers/md/bcache/writeback.c
index 42c66e76f05e..b533c2292ba5 100644
--- a/drivers/md/bcache/writeback.c
+++ b/drivers/md/bcache/writeback.c
@@ -21,7 +21,8 @@
static void __update_writeback_rate(struct cached_dev *dc)
{
struct cache_set *c = dc->disk.c;
- uint64_t cache_sectors = c->nbuckets * c->sb.bucket_size;
+ uint64_t cache_sectors = c->nbuckets * c->sb.bucket_size -
+ bcache_flash_devs_sectors_dirty(c);
uint64_t cache_dirty_target =
div_u64(cache_sectors * dc->writeback_percent, 100);
diff --git a/drivers/md/bcache/writeback.h b/drivers/md/bcache/writeback.h
index 629bd1a502fd..8789b9c8c484 100644
--- a/drivers/md/bcache/writeback.h
+++ b/drivers/md/bcache/writeback.h
@@ -14,6 +14,25 @@ static inline uint64_t bcache_dev_sectors_dirty(struct bcache_device *d)
return ret;
}
+static inline uint64_t bcache_flash_devs_sectors_dirty(struct cache_set *c)
+{
+ uint64_t i, ret = 0;
+
+ mutex_lock(&bch_register_lock);
+
+ for (i = 0; i < c->nr_uuids; i++) {
+ struct bcache_device *d = c->devices[i];
+
+ if (!d || !UUID_FLASH_ONLY(&c->uuids[i]))
+ continue;
+ ret += bcache_dev_sectors_dirty(d);
+ }
+
+ mutex_unlock(&bch_register_lock);
+
+ return ret;
+}
+
static inline unsigned offset_to_stripe(struct bcache_device *d,
uint64_t offset)
{
--
2.13.5
next prev parent reply other threads:[~2017-09-06 6:26 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-06 6:25 [PATCH 00/13] bcache: fixes and update for 4.14 Coly Li
2017-09-06 6:25 ` [PATCH 01/12] bcache: Fix leak of bdev reference Coly Li
2017-09-06 6:25 ` [PATCH 02/12] bcache: fix sequential large write IO bypass Coly Li
2017-09-06 6:25 ` [PATCH 03/12] bcache: do not subtract sectors_to_gc for bypassed IO Coly Li
2017-09-06 6:25 ` [PATCH 04/12] bcache: Don't reinvent the wheel but use existing llist API Coly Li
2017-09-26 4:38 ` Michael Lyle
2017-09-26 6:39 ` 박병철/선임연구원/SW Platform(연)AOT팀(byungchul.park@lge.com)
2017-09-26 7:09 ` Coly Li
2017-09-26 7:15 ` 박병철/선임연구원/SW Platform(연)AOT팀(byungchul.park@lge.com)
2017-09-26 7:22 ` Coly Li
2017-09-26 7:08 ` Coly Li
2017-09-26 7:16 ` 박병철/선임연구원/SW Platform(연)AOT팀(byungchul.park@lge.com)
2017-09-26 7:24 ` Coly Li
2017-09-26 7:46 ` Coly Li
2017-09-26 19:55 ` Michael Lyle
2017-09-06 6:25 ` [PATCH 05/12] bcache: gc does not work when triggering by manual command Coly Li
2017-09-06 6:25 ` Coly Li [this message]
2017-09-06 6:25 ` [PATCH 07/12] bcache: Correct return value for sysfs attach errors Coly Li
2017-09-06 6:25 ` [PATCH 08/12] bcache: increase the number of open buckets Coly Li
2017-09-06 6:25 ` [PATCH 09/12] bcache: fix for gc and write-back race Coly Li
2017-09-06 6:26 ` [PATCH 10/12] bcache: silence static checker warning Coly Li
2017-09-06 6:26 ` [PATCH 11/12] bcache: Update continue_at() documentation Coly Li
2017-09-06 6:26 ` [PATCH 12/12] bcache: fix bch_hprint crash and improve output Coly Li
2017-09-06 14:20 ` [PATCH 00/13] bcache: fixes and update for 4.14 Jens Axboe
2017-09-06 15:41 ` Coly Li
2017-09-06 15:46 ` Jens Axboe
2017-09-06 17:38 ` Coly Li
2017-09-07 18:51 ` Eddie Chapman
2017-09-07 19:31 ` Jens Axboe
2017-09-07 19:01 ` Eddie Chapman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170906062602.50497-7-colyli@suse.de \
--to=colyli@suse.de \
--cc=axboe@kernel.dk \
--cc=bcache@lists.ewheeler.net \
--cc=linux-bcache@vger.kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=tang.junhui@zte.com.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox