linux/drivers/md/bcache
Shenghui Wang 79b791466e bcache: do not mark writeback_running too early
A fresh backing device is not attached to any cache_set, and
has no writeback kthread created until first attached to some
cache_set.

But bch_cached_dev_writeback_init run
"
	dc->writeback_running		= true;
	WARN_ON(test_and_clear_bit(BCACHE_DEV_WB_RUNNING,
			&dc->disk.flags));
"
for any newly formatted backing devices.

For a fresh standalone backing device, we can get something like
following even if no writeback kthread created:
------------------------
/sys/block/bcache0/bcache# cat writeback_running
1
/sys/block/bcache0/bcache# cat writeback_rate_debug
rate:		512.0k/sec
dirty:		0.0k
target:		0.0k
proportional:	0.0k
integral:	0.0k
change:		0.0k/sec
next io:	-15427384ms

The none ZERO fields are misleading as no alive writeback kthread yet.

Set dc->writeback_running false as no writeback thread created in
bch_cached_dev_writeback_init().

We have writeback thread created and woken up in bch_cached_dev_writeback
_start(). Set dc->writeback_running true before bch_writeback_queue()
called, as a writeback thread will check if dc->writeback_running is true
before writing back dirty data, and hung if false detected.

After the change, we can get the following output for a fresh standalone
backing device:
-----------------------
/sys/block/bcache0/bcache$ cat writeback_running
0
/sys/block/bcache0/bcache# cat writeback_rate_debug
rate:		0.0k/sec
dirty:		0.0k
target:		0.0k
proportional:	0.0k
integral:	0.0k
change:		0.0k/sec
next io:	0ms

v1 -> v2:
  Set dc->writeback_running before bch_writeback_queue() called,

Signed-off-by: Shenghui Wang <shhuiw@foxmail.com>
Signed-off-by: Coly Li <colyli@suse.de>

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2018-12-13 08:15:54 -07:00
..
alloc.c bcache: use MAX_CACHES_PER_SET instead of magic number 8 in __bch_bucket_alloc_set 2018-10-08 08:19:56 -06:00
bcache.h bcache: add comment for cache_set->fill_iter 2018-12-13 08:15:54 -07:00
bset.c bcache: fix code comments style 2018-08-11 15:46:42 -06:00
bset.h bcache: style fixes for lines over 80 characters 2018-08-11 15:46:41 -06:00
btree.c bcache: add comment for cache_set->fill_iter 2018-12-13 08:15:54 -07:00
btree.h bcache: style fixes for lines over 80 characters 2018-08-11 15:46:41 -06:00
closure.c bcache: add missing SPDX header 2018-08-11 15:46:42 -06:00
closure.h bcache: fix typo in code comments of closure_return_with_destructor() 2018-10-08 08:19:43 -06:00
debug.c bcache: do not check if debug dentry is ERR or NULL explicitly on remove 2018-12-13 08:15:54 -07:00
debug.h bcache: add identifier names to arguments of function definitions 2018-08-11 15:46:41 -06:00
extents.c bcache: replace hard coded number with BUCKET_GC_GEN_MAX 2018-10-08 08:19:55 -06:00
extents.h bcache: add identifier names to arguments of function definitions 2018-08-11 15:46:41 -06:00
io.c bcache: fix typo 'succesfully' to 'successfully' 2018-08-11 15:46:42 -06:00
journal.c bcache: add separate workqueue for journal_write to avoid deadlock 2018-09-27 09:47:01 -06:00
journal.h bcache: add identifier names to arguments of function definitions 2018-08-11 15:46:41 -06:00
Kconfig for-4.19/post-20180822 2018-08-22 13:38:05 -07:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
movinggc.c bcache: style fix to add a blank line after declarations 2018-08-11 15:46:41 -06:00
request.c bcache: update comment for bch_data_insert 2018-12-13 08:15:54 -07:00
request.h bcache: remove unused bch_passthrough_cache 2018-10-08 08:19:52 -06:00
stats.c bcache: style fix to add a blank line after declarations 2018-08-11 15:46:41 -06:00
stats.h bcache: add identifier names to arguments of function definitions 2018-08-11 15:46:41 -06:00
super.c bcache: do not check if debug dentry is ERR or NULL explicitly on remove 2018-12-13 08:15:54 -07:00
sysfs.c bcache: update comment in sysfs.c 2018-12-13 08:15:54 -07:00
sysfs.h bcache: replace Symbolic permissions by octal permission numbers 2018-08-11 15:46:41 -06:00
trace.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
util.c for-4.19/post-20180822 2018-08-22 13:38:05 -07:00
util.h for-4.19/post-20180822 2018-08-22 13:38:05 -07:00
writeback.c bcache: do not mark writeback_running too early 2018-12-13 08:15:54 -07:00
writeback.h bcache: add identifier names to arguments of function definitions 2018-08-11 15:46:41 -06:00