bcache: Avoid hung task happen.
PATCH 2/3 bcache: Avoid hung task happen.
Because after kthread_create, the state of kthread is TASK_UNINTERRUPTIBLE. If we don't wake up dc->writeback_thread, the thread will be hung-task. For those reasons, we don't wake up writeback_thread:
A:only create backed device
B:create backed device and cache device, but don't write at once C:write without writeback poliy
So like the way of create gc_thread, after creating writeback_thread, i set the state is TASK_INTERRUPTIBLE.
--- drivers/md/bcache/writeback.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/md/bcache/writeback.c +2 -0
@@ -499,6 +499,8 @@ int bch_cached_dev_writeback_init(struct cached_dev *dc)if (IS_ERR (dc->writeback_thread))return PTR_ERR (dc->writeback_thread); +set_task_state (dc->writeback_thread,TASK_INTERRUPTIBLE ); +INIT_DELAYED_WORK (&dc->writeback_rate_update, update_writeback_rate);schedule_delayed_work (&dc->writeback_rate_update, dc->writeback_rate_update_seconds *HZ );
Signature · 1 line
1.7.10.4
Quoted 9 lines · majianpeng
Because after
kthread_create, the state of kthread isTASK_UNINTERRUPTIBLE. If we don't wake updc->writeback_thread, the thread will be hung-task. For those reasons, we don't wake upwriteback_thread:
A:only create backed device
B:create backed device and cache device, but don't write at once C:write without writeback poliySo like the way of create
gc_thread, after creatingwriteback_thread, i set the state isTASK_INTERRUPTIBLE.
I've seen this issue, but this isn't even where the sleep happens, there's no way this could be fixing it..
Quoted 8 lines · majianpeng
Quoted 7 lines
Because after
kthread_create, the state of kthread isTASK_UNINTERRUPTIBLE. If we don't wake updc->writeback_thread, the thread will be hung-task. For those reasons, we don't wake upwriteback_thread:
A:only create backed device
B:create backed device and cache device, but don't write at once C:write without writeback poliy
Quoted 5 lines
Quoted 2 lines
So like the way of create
gc_thread, after creatingwriteback_thread, i set the state isTASK_INTERRUPTIBLE.I've seen this issue, but this isn't even where the sleep happens, there's no way this could be fixing it..
Yes.But now, the default cache mode is writethrough.So kernel also printk hung-task messages. If you don't like this way, you can use kthread_run instead kthread_create. Because you test dc->has_dirty in bch_writeback_thread,so using kthread_run is safe.
Thanks!
Jianpeng Ma