* [PATCH 0/1] bcache fix for 4.19-rc6
@ 2018-09-27 15:41 Coly Li
2018-09-27 15:41 ` [PATCH 1/1] bcache: add separate workqueue for journal_write to avoid deadlock Coly Li
0 siblings, 1 reply; 6+ messages in thread
From: Coly Li @ 2018-09-27 15:41 UTC (permalink / raw)
To: linux-bcache, axboe; +Cc: linux-block, Coly Li
Hi Jens,
Guoju Fang just posts a bug fix to solve a bcache journal deadlock.
This bug probably happens when system memory is in heavy usage,
the deadlock is observed occasionally for a long while.
If it is too late to go into Linux 4.19, I will submit to you in
4.20 merge window, but it will be cool to have it in this run.
Thanks.
Coly Li
guoju (1):
bcache: add separate workqueue for journal_write to avoid deadlock
drivers/md/bcache/bcache.h | 1 +
drivers/md/bcache/journal.c | 6 +++---
drivers/md/bcache/super.c | 8 ++++++++
3 files changed, 12 insertions(+), 3 deletions(-)
--
2.19.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/1] bcache: add separate workqueue for journal_write to avoid deadlock
2018-09-27 15:41 [PATCH 0/1] bcache fix for 4.19-rc6 Coly Li
@ 2018-09-27 15:41 ` Coly Li
2018-09-27 15:46 ` Jens Axboe
0 siblings, 1 reply; 6+ messages in thread
From: Coly Li @ 2018-09-27 15:41 UTC (permalink / raw)
To: linux-bcache, axboe; +Cc: linux-block, guoju, stable, Coly Li
From: guoju <fangguoju@gmail.com>
After write SSD completed, bcache schedules journal_write work to
system_wq, which is a public workqueue in system, without WQ_MEM_RECLAIM
flag. system_wq is also a bound wq, and there may be no idle kworker on
current processor. Creating a new kworker may unfortunately need to
reclaim memory first, by shrinking cache and slab used by vfs, which
depends on bcache device. That's a deadlock.
This patch create a new workqueue for journal_write with WQ_MEM_RECLAIM
flag. It's rescuer thread will work to avoid the deadlock.
Signed-off-by: guoju <fangguoju@gmail.com>
Cc: stable@vger.kernel.org
Signed-off-by: Coly Li <colyli@suse.de>
---
drivers/md/bcache/bcache.h | 1 +
drivers/md/bcache/journal.c | 6 +++---
drivers/md/bcache/super.c | 8 ++++++++
3 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h
index 83504dd8100a..954dad29e6e8 100644
--- a/drivers/md/bcache/bcache.h
+++ b/drivers/md/bcache/bcache.h
@@ -965,6 +965,7 @@ void bch_prio_write(struct cache *ca);
void bch_write_bdev_super(struct cached_dev *dc, struct closure *parent);
extern struct workqueue_struct *bcache_wq;
+extern struct workqueue_struct *bch_journal_wq;
extern struct mutex bch_register_lock;
extern struct list_head bch_cache_sets;
diff --git a/drivers/md/bcache/journal.c b/drivers/md/bcache/journal.c
index 6116bbf870d8..522c7426f3a0 100644
--- a/drivers/md/bcache/journal.c
+++ b/drivers/md/bcache/journal.c
@@ -485,7 +485,7 @@ static void do_journal_discard(struct cache *ca)
closure_get(&ca->set->cl);
INIT_WORK(&ja->discard_work, journal_discard_work);
- schedule_work(&ja->discard_work);
+ queue_work(bch_journal_wq, &ja->discard_work);
}
}
@@ -592,7 +592,7 @@ static void journal_write_done(struct closure *cl)
: &j->w[0];
__closure_wake_up(&w->wait);
- continue_at_nobarrier(cl, journal_write, system_wq);
+ continue_at_nobarrier(cl, journal_write, bch_journal_wq);
}
static void journal_write_unlock(struct closure *cl)
@@ -627,7 +627,7 @@ static void journal_write_unlocked(struct closure *cl)
spin_unlock(&c->journal.lock);
btree_flush_write(c);
- continue_at(cl, journal_write, system_wq);
+ continue_at(cl, journal_write, bch_journal_wq);
return;
}
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index 94c756c66bd7..30ba9aeb5ee8 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -47,6 +47,7 @@ static int bcache_major;
static DEFINE_IDA(bcache_device_idx);
static wait_queue_head_t unregister_wait;
struct workqueue_struct *bcache_wq;
+struct workqueue_struct *bch_journal_wq;
#define BTREE_MAX_PAGES (256 * 1024 / PAGE_SIZE)
/* limitation of partitions number on single bcache device */
@@ -2341,6 +2342,9 @@ static void bcache_exit(void)
kobject_put(bcache_kobj);
if (bcache_wq)
destroy_workqueue(bcache_wq);
+ if (bch_journal_wq)
+ destroy_workqueue(bch_journal_wq);
+
if (bcache_major)
unregister_blkdev(bcache_major, "bcache");
unregister_reboot_notifier(&reboot);
@@ -2370,6 +2374,10 @@ static int __init bcache_init(void)
if (!bcache_wq)
goto err;
+ bch_journal_wq = alloc_workqueue("bch_journal", WQ_MEM_RECLAIM, 0);
+ if (!bch_journal_wq)
+ goto err;
+
bcache_kobj = kobject_create_and_add("bcache", fs_kobj);
if (!bcache_kobj)
goto err;
--
2.19.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/1] bcache: add separate workqueue for journal_write to avoid deadlock
2018-09-27 15:41 ` [PATCH 1/1] bcache: add separate workqueue for journal_write to avoid deadlock Coly Li
@ 2018-09-27 15:46 ` Jens Axboe
2018-09-27 15:57 ` 国炬方
0 siblings, 1 reply; 6+ messages in thread
From: Jens Axboe @ 2018-09-27 15:46 UTC (permalink / raw)
To: Coly Li, linux-bcache; +Cc: linux-block, guoju, stable
On 9/27/18 9:41 AM, Coly Li wrote:
> From: guoju <fangguoju@gmail.com>
This, and the signed-off, should use the full name. I can fix that up,
assuming Guoju Fang is the full name?
--
Jens Axboe
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/1] bcache: add separate workqueue for journal_write to avoid deadlock
2018-09-27 15:46 ` Jens Axboe
@ 2018-09-27 15:57 ` 国炬方
2018-09-27 16:06 ` Jens Axboe
0 siblings, 1 reply; 6+ messages in thread
From: 国炬方 @ 2018-09-27 15:57 UTC (permalink / raw)
To: Jens Axboe; +Cc: Coly Li, linux-bcache, linux-block, stable
[-- Attachment #1: Type: text/plain, Size: 324 bytes --]
Yes, Guoju Fang. Thx. :)
Jens Axboe <axboe@kernel.dk>于2018年9月27日 周四23:46写道:
> On 9/27/18 9:41 AM, Coly Li wrote:
> > From: guoju <fangguoju@gmail.com>
>
> This, and the signed-off, should use the full name. I can fix that up,
> assuming Guoju Fang is the full name?
>
> --
> Jens Axboe
>
>
[-- Attachment #2: Type: text/html, Size: 665 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/1] bcache: add separate workqueue for journal_write to avoid deadlock
2018-09-27 15:57 ` 国炬方
@ 2018-09-27 16:06 ` Jens Axboe
2018-09-27 16:23 ` Guoju Fang
0 siblings, 1 reply; 6+ messages in thread
From: Jens Axboe @ 2018-09-27 16:06 UTC (permalink / raw)
To: 国炬方; +Cc: Coly Li, linux-bcache, linux-block, stable
On 9/27/18 9:57 AM, 国炬方 wrote:
> Yes, Guoju Fang. Thx. :)
OK, I made that change and committed it. Just be sure to use your full
name in the future for signoffs, etc.
--
Jens Axboe
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/1] bcache: add separate workqueue for journal_write to avoid deadlock
2018-09-27 16:06 ` Jens Axboe
@ 2018-09-27 16:23 ` Guoju Fang
0 siblings, 0 replies; 6+ messages in thread
From: Guoju Fang @ 2018-09-27 16:23 UTC (permalink / raw)
To: Jens Axboe; +Cc: Coly Li, linux-bcache, linux-block, stable
[-- Attachment #1: Type: text/plain, Size: 309 bytes --]
Will do, thanks!
Jens Axboe <axboe@kernel.dk>于2018年9月28日 周五00:06写道:
> On 9/27/18 9:57 AM, 国炬方 wrote:
> > Yes, Guoju Fang. Thx. :)
>
> OK, I made that change and committed it. Just be sure to use your full
> name in the future for signoffs, etc.
>
> --
> Jens Axboe
>
>
[-- Attachment #2: Type: text/html, Size: 565 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-09-27 16:23 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-27 15:41 [PATCH 0/1] bcache fix for 4.19-rc6 Coly Li
2018-09-27 15:41 ` [PATCH 1/1] bcache: add separate workqueue for journal_write to avoid deadlock Coly Li
2018-09-27 15:46 ` Jens Axboe
2018-09-27 15:57 ` 国炬方
2018-09-27 16:06 ` Jens Axboe
2018-09-27 16:23 ` Guoju Fang
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.