* [PATCH] bcache: Fix a sleep-in-atomic bug
@ 2017-05-31 7:23 Jia-Ju Bai
2017-05-31 7:52 ` Kent Overstreet
2017-05-31 8:31 ` Jia-Ju Bai
0 siblings, 2 replies; 3+ messages in thread
From: Jia-Ju Bai @ 2017-05-31 7:23 UTC (permalink / raw)
To: kent.overstreet, shli, axboe, mchristi, git, colyli, akpm,
wangyijing, mingo, mhocko
Cc: linux-bcache, linux-raid, linux-kernel, Jia-Ju Bai
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
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] bcache: Fix a sleep-in-atomic bug
2017-05-31 7:23 [PATCH] bcache: Fix a sleep-in-atomic bug Jia-Ju Bai
@ 2017-05-31 7:52 ` Kent Overstreet
2017-05-31 8:31 ` Jia-Ju Bai
1 sibling, 0 replies; 3+ messages in thread
From: Kent Overstreet @ 2017-05-31 7:52 UTC (permalink / raw)
To: Jia-Ju Bai
Cc: shli, axboe, mchristi, git, colyli, akpm, wangyijing, mingo,
mhocko, linux-bcache, linux-raid, linux-kernel
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
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] bcache: Fix a sleep-in-atomic bug
2017-05-31 7:23 [PATCH] bcache: Fix a sleep-in-atomic bug Jia-Ju Bai
2017-05-31 7:52 ` Kent Overstreet
@ 2017-05-31 8:31 ` Jia-Ju Bai
1 sibling, 0 replies; 3+ messages in thread
From: Jia-Ju Bai @ 2017-05-31 8:31 UTC (permalink / raw)
To: Jia-Ju Bai
Cc: kent.overstreet, shli, axboe, mchristi, git, colyli, akpm,
wangyijing, mingo, mhocko, linux-bcache, linux-raid,
linux-kernel
On 05/31/2017 03:23 PM, 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
>
> 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;
Sorry, my patch is not correct, and it will cause double unlock.
Please ignore my patch.
Jia-Ju Bai
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-05-31 8:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-31 7:23 [PATCH] bcache: Fix a sleep-in-atomic bug Jia-Ju Bai
2017-05-31 7:52 ` Kent Overstreet
2017-05-31 8:31 ` Jia-Ju Bai
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.