From: Coly Li <colyli@suse.de>
To: Zou Mingzhe <mingzhe.zou@easystack.cn>
Cc: linux-bcache@vger.kernel.org, dongsheng.yang@easystack.cn,
zoumingzhe@qq.com
Subject: Re: [PATCH] bcache: try to reuse the slot of invalid_uuid
Date: Mon, 6 Jun 2022 18:34:33 +0800 [thread overview]
Message-ID: <31FA99EB-4E02-4241-9264-248A03FABA4E@suse.de> (raw)
In-Reply-To: <f19c392f-6ad8-9e0c-a8f7-de2339f76cb6@easystack.cn>
> 2022年6月6日 17:29,Zou Mingzhe <mingzhe.zou@easystack.cn> 写道:
>
>
>
> 在 2022/6/6 16:57, Coly Li 写道:
>>
>>> 2022年6月6日 16:45,mingzhe.zou@easystack.cn
>>> 写道:
>>>
>>> From: mingzhe
>>> <mingzhe.zou@easystack.cn>
>>>
>>>
>>>
>>>
>> [snipped]
>>
>>
>>> We want to use those invalid_uuid slots carefully. Because, the bkey of the inode
>>> may still exist in the btree. So, we need to check the btree before reuse it.
>>>
>>> Signed-off-by: mingzhe
>>> <mingzhe.zou@easystack.cn>
>>>
>>> ---
>>> drivers/md/bcache/btree.c | 35 +++++++++++++++++++++++++++++++++++
>>> drivers/md/bcache/btree.h | 1 +
>>> drivers/md/bcache/super.c | 15 ++++++++++++++-
>>> 3 files changed, 50 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c
>>> index e136d6edc1ed..a5d54af73111 100644
>>> --- a/drivers/md/bcache/btree.c
>>> +++ b/drivers/md/bcache/btree.c
>>> @@ -2755,6 +2755,41 @@ struct keybuf_key *bch_keybuf_next_rescan(struct cache_set *c,
>>> return ret;
>>> }
>>>
>>> +static bool check_pred(struct keybuf *buf, struct bkey *k)
>>> +{
>>> + return true;
>>> +}
>>> +
>>> +bool bch_btree_can_inode_reuse(struct cache_set *c, size_t inode)
>>> +{
>>> + bool ret = true;
>>> + struct keybuf_key *k;
>>> + struct bkey end_key = KEY(inode, MAX_KEY_OFFSET, 0);
>>> + struct keybuf *keys = kzalloc(sizeof(struct keybuf), GFP_KERNEL);
>>> +
>>> + if (!keys) {
>>> + ret = false;
>>> + goto out;
>>> + }
>>> +
>>> + bch_keybuf_init(keys);
>>> + keys->last_scanned = KEY(inode, 0, 0);
>>> +
>>> + while (ret) {
>>> + k = bch_keybuf_next_rescan(c, keys, &end_key, check_pred);
>>> + if (!k)
>>>
>>
>> This is a single thread iteration, for a large filled cache device it can be very slow. I observed 40+ minutes during my testing.
>>
>>
>> Coly Li
>>
>>
> Hi, Coly
>
> We first use the zero_uuid slot, and reuse only if there is no zero_uuid slot. This is just an imperfect solution to make bcache available, so we haven't tested its performance. We think we will eventually need to actively clean up these bkeys in a new thread and reset the invalid_uuid to zero_uuid.
Current method is the simplest, trust me, there is no much fun to play with register lock, writeback lock, and the btree node locks, live is not easy already...
Coly Li
next prev parent reply other threads:[~2022-06-06 10:34 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-06 8:45 [PATCH] bcache: try to reuse the slot of invalid_uuid mingzhe.zou
2022-06-06 8:57 ` Coly Li
2022-06-06 9:36 ` Zou Mingzhe
[not found] ` <f19c392f-6ad8-9e0c-a8f7-de2339f76cb6@easystack.cn>
2022-06-06 10:34 ` Coly Li [this message]
2022-06-13 8:20 ` Zou Mingzhe
2022-06-13 8:35 ` 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=31FA99EB-4E02-4241-9264-248A03FABA4E@suse.de \
--to=colyli@suse.de \
--cc=dongsheng.yang@easystack.cn \
--cc=linux-bcache@vger.kernel.org \
--cc=mingzhe.zou@easystack.cn \
--cc=zoumingzhe@qq.com \
/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