From: Coly Li <colyli@suse.de>
To: Mauricio Faria de Oliveira <mfo@canonical.com>
Cc: linux-bcache@vger.kernel.org, nkshirsagar@gmail.com,
kent.overstreet@gmail.com
Subject: Re: bcache-register hang after reboot
Date: Wed, 15 Dec 2021 00:06:27 +0800 [thread overview]
Message-ID: <77a855ff-fb0d-5c7b-d2fd-24d58beb6a07@suse.de> (raw)
In-Reply-To: <20211213220455.1633987-1-mfo@canonical.com>
On 12/14/21 6:04 AM, Mauricio Faria de Oliveira wrote:
> Hey Kent and Coly,
>
> It turns out that, at least for the disk image that reproduces the issue,
> the closure from bch_btree_set_root() to bch_journal_meta() doesn't make
> a difference; the stall is in bch_journal() -> journal_wait_for_write().
>
> So the previous suggestion to skip bch_journal_meta() altogether works,
> to get things going.. of course, checking for journal replay/full case.
>
> What do you think of this patch?
>
> It simply checks the conditions in run_cache_set() for bch_journal_replay().
> (it starts w/ unlikely(!CACHE_SET_RUNNING) to quickly get to the usual case,
> and apparently has an extra strict check for !gc_thread, just in case.
> And it is journal_full() only, as the !journal_full() case in journal_wait_
> for_write() seems to be handled via another function per the comment.)
>
> This works w/ the disk image here.
Hi Mauricio,
The following patch might work but not a proper fix. I am in travel
recently, and hope soon I may have time to refine a patch for such
non-space issue for journal.
I have a patch but it need to be rebased with the latest bcache code.
Thanks.
Coly Li
>
> Thanks!
> Mauricio
>
> diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c
> index 72abe5cf4b12..bedeffc3ae28 100644
> --- a/drivers/md/bcache/btree.c
> +++ b/drivers/md/bcache/btree.c
> @@ -2477,9 +2477,6 @@ int bch_btree_insert(struct cache_set *c, struct keylist *keys,
> void bch_btree_set_root(struct btree *b)
> {
> unsigned int i;
> - struct closure cl;
> -
> - closure_init_stack(&cl);
>
> trace_bcache_btree_set_root(b);
>
> @@ -2494,8 +2491,18 @@ void bch_btree_set_root(struct btree *b)
>
> b->c->root = b;
>
> - bch_journal_meta(b->c, &cl);
> - closure_sync(&cl);
> + /* Don't journal during replay if journal is full (prevents deadlock) */
> + if (unlikely(!test_bit(CACHE_SET_RUNNING, &b->c->flags)) &&
> + CACHE_SYNC(&b->c->cache->sb) && b->c->gc_thread == NULL &&
> + journal_full(&b->c->journal)) {
> + pr_info("Not journaling new root (replay with full journal)\n");
> + } else {
> + struct closure cl;
> +
> + closure_init_stack(&cl);
> + bch_journal_meta(b->c, &cl);
> + closure_sync(&cl);
> + }
> }
>
> /* Map across nodes or keys */
next prev parent reply other threads:[~2021-12-14 16:06 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-10 5:44 bcache-register hang after reboot Nikhil Kshirsagar
2021-11-10 20:13 ` Kent Overstreet
2021-11-11 20:54 ` Mauricio Oliveira
2021-11-13 18:05 ` Kent Overstreet
2021-12-13 22:04 ` Mauricio Faria de Oliveira
2021-12-13 22:22 ` Mauricio Faria de Oliveira
2021-12-14 16:06 ` Coly Li [this message]
2021-12-14 16:43 ` Mauricio Faria de Oliveira
2021-11-12 5:45 ` Coly Li
2021-11-13 18:12 ` Kent Overstreet
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=77a855ff-fb0d-5c7b-d2fd-24d58beb6a07@suse.de \
--to=colyli@suse.de \
--cc=kent.overstreet@gmail.com \
--cc=linux-bcache@vger.kernel.org \
--cc=mfo@canonical.com \
--cc=nkshirsagar@gmail.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;
as well as URLs for NNTP newsgroup(s).