From: Kent Overstreet <kent.overstreet@gmail.com>
To: Jia-Ju Bai <baijiaju1990@163.com>
Cc: shli@kernel.org, axboe@fb.com, mchristi@redhat.com,
git@linux.ewheeler.net, colyli@suse.de,
akpm@linux-foundation.org, wangyijing@huawei.com,
mingo@kernel.org, mhocko@suse.com, linux-bcache@vger.kernel.org,
linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] bcache: Fix a sleep-in-atomic bug
Date: Tue, 30 May 2017 23:52:10 -0800 [thread overview]
Message-ID: <20170531075209.xrcvxp3uh3yjupiv@moria.home.lan> (raw)
In-Reply-To: <1496215420-15819-1-git-send-email-baijiaju1990@163.com>
On Wed, May 31, 2017 at 03:23:40PM +0800, Jia-Ju Bai wrote:
> The driver may sleep under a spin lock, and the function call path is:
> journal_wait_for_write (acquire the lock by spin_lock)
> closure_sync
> schedule --> may sleep
This patch is incorrect, you've introduced a double unlock.
Did you actually observe a sleep in atomic?
>
> To fix it, the lock is released before "closure_sync", and the lock is
> acquired again after this function.
>
> Signed-off-by: Jia-Ju Bai <baijiaju1990@163.com>
> ---
> drivers/md/bcache/journal.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/md/bcache/journal.c b/drivers/md/bcache/journal.c
> index 1198e53..ad47c36 100644
> --- a/drivers/md/bcache/journal.c
> +++ b/drivers/md/bcache/journal.c
> @@ -724,6 +724,7 @@ static struct journal_write *journal_wait_for_write(struct cache_set *c,
> btree_flush_write(c);
> }
>
> + spin_unlock(&c->journal.lock);
> closure_sync(&cl);
> spin_lock(&c->journal.lock);
> wait = true;
> --
> 1.7.9.5
>
>
next prev parent reply other threads:[~2017-05-31 7:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-31 7:23 [PATCH] bcache: Fix a sleep-in-atomic bug Jia-Ju Bai
2017-05-31 7:52 ` Kent Overstreet [this message]
2017-05-31 8:31 ` Jia-Ju Bai
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=20170531075209.xrcvxp3uh3yjupiv@moria.home.lan \
--to=kent.overstreet@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=axboe@fb.com \
--cc=baijiaju1990@163.com \
--cc=colyli@suse.de \
--cc=git@linux.ewheeler.net \
--cc=linux-bcache@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=mchristi@redhat.com \
--cc=mhocko@suse.com \
--cc=mingo@kernel.org \
--cc=shli@kernel.org \
--cc=wangyijing@huawei.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.