lkml.org 
[lkml]   [2017]   [May]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] bcache: Fix a sleep-in-atomic bug
Date
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

\
 
 \ /
  Last update: 2017-05-31 09:26    [W:0.049 / U:0.048 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site