From: Coly Li <colyli@suse.de>
To: Yaowei Bai <baiyaowei@cmss.chinamobile.com>
Cc: kent.overstreet@gmail.com, linux-bcache@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] bcache: count cache_available_percent accurately
Date: Sat, 27 Jul 2019 22:39:30 +0800 [thread overview]
Message-ID: <aff72e17-a36d-4bb8-28e2-49af07dc72ad@suse.de> (raw)
In-Reply-To: <1564222799-10603-3-git-send-email-baiyaowei@cmss.chinamobile.com>
On 2019/7/27 6:19 下午, Yaowei Bai wrote:
> The interface cache_available_percent is used to indicate how
> many buckets in percent are available to be used to cache data
> at a specific moment. It should include the unused and clean
> buckets which we get from bch_btree_gc_finish function:
>
> if (!GC_MARK(b) || GC_MARK(b) == GC_MARK_RECLAIMABLE)
> c->avail_nbuckets++;
>
> However currently in the allocation code we didn't distinguish
> these available buckets with the metadata and dirty buckets, we
> just decrease the c->avail_nbuckets everytime we allocate a bucket,
> and correct it after a gc completes. With this, in a read-only
> scenario, you can observe that cache_available_percent bounces,
> it first go down to a number, like 95, and then bounces back to
> 100. It goes on and on, making users confused.
Hmm, I don't feel it could be confused, indeed I feel this is what is
designed for, counting both data/meta data buckets allocation. We can
document in admin-guide/bcache.rst, and notice people that even for
read-only requests, buckets can also be allocated for metadata.
Thanks.
Coly Li
>
> This patch fixes this problem by decreasing c->avail_nbuckets
> only when allocate metadata and dirty buckets. With this patch,
> cache_available_percent will always be accurate and avoid the
> confusion.
>
> Signed-off-by: Yaowei Bai <baiyaowei@cmss.chinamobile.com>
> ---
> drivers/md/bcache/alloc.c | 10 +++++-----
> drivers/md/bcache/request.c | 9 ++++++++-
> 2 files changed, 13 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/md/bcache/alloc.c b/drivers/md/bcache/alloc.c
> index 609df38..dc7f6c2 100644
> --- a/drivers/md/bcache/alloc.c
> +++ b/drivers/md/bcache/alloc.c
> @@ -443,17 +443,17 @@ long bch_bucket_alloc(struct cache *ca, unsigned int reserve, bool wait)
> SET_GC_MARK(b, GC_MARK_METADATA);
> SET_GC_MOVE(b, 0);
> b->prio = BTREE_PRIO;
> +
> + if (ca->set->avail_nbuckets > 0) {
> + ca->set->avail_nbuckets--;
> + bch_update_bucket_in_use(ca->set, &ca->set->gc_stats);
> + }
> } else {
> SET_GC_MARK(b, GC_MARK_RECLAIMABLE);
> SET_GC_MOVE(b, 0);
> b->prio = INITIAL_PRIO;
> }
>
> - if (ca->set->avail_nbuckets > 0) {
> - ca->set->avail_nbuckets--;
> - bch_update_bucket_in_use(ca->set, &ca->set->gc_stats);
> - }
> -
> return r;
> }
>
> diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c
> index 41adcd1..b69bd8d 100644
> --- a/drivers/md/bcache/request.c
> +++ b/drivers/md/bcache/request.c
> @@ -244,9 +244,16 @@ static void bch_data_insert_start(struct closure *cl)
> if (op->writeback) {
> SET_KEY_DIRTY(k, true);
>
> - for (i = 0; i < KEY_PTRS(k); i++)
> + for (i = 0; i < KEY_PTRS(k); i++) {
> SET_GC_MARK(PTR_BUCKET(op->c, k, i),
> GC_MARK_DIRTY);
> +
> + if (op->c->avail_nbuckets > 0) {
> + op->c->avail_nbuckets--;
> + bch_update_bucket_in_use(op->c,
> + &op->c->gc_stats);
> + }
> + }
> }
>
> SET_KEY_CSUM(k, op->csum);
>
next prev parent reply other threads:[~2019-07-27 14:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-27 10:19 [PATCH 1/3] bcache: drop obsolete comments Yaowei Bai
2019-07-27 10:19 ` [PATCH 2/3] bcache: use allocator reserves instead of watermarks Yaowei Bai
2019-07-27 14:13 ` Coly Li
2019-07-27 10:19 ` [PATCH 3/3] bcache: count cache_available_percent accurately Yaowei Bai
2019-07-27 14:39 ` Coly Li [this message]
2019-07-27 14:12 ` [PATCH 1/3] bcache: drop obsolete comments Coly Li
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=aff72e17-a36d-4bb8-28e2-49af07dc72ad@suse.de \
--to=colyli@suse.de \
--cc=baiyaowei@cmss.chinamobile.com \
--cc=kent.overstreet@gmail.com \
--cc=linux-bcache@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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
all inboxes | Powered by JetHome®