linux-stable/drivers/md/bcache
Coly Li 622536443b bcache: improve multithreaded bch_btree_check()
Commit 8e7102273f ("bcache: make bch_btree_check() to be
multithreaded") makes bch_btree_check() to be much faster when checking
all btree nodes during cache device registration. But it isn't in ideal
shap yet, still can be improved.

This patch does the following thing to improve current parallel btree
nodes check by multiple threads in bch_btree_check(),
- Add read lock to root node while checking all the btree nodes with
  multiple threads. Although currently it is not mandatory but it is
  good to have a read lock in code logic.
- Remove local variable 'char name[32]', and generate kernel thread name
  string directly when calling kthread_run().
- Allocate local variable "struct btree_check_state check_state" on the
  stack and avoid unnecessary dynamic memory allocation for it.
- Reduce BCH_BTR_CHKTHREAD_MAX from 64 to 12 which is enough indeed.
- Increase check_state->started to count created kernel thread after it
  succeeds to create.
- When wait for all checking kernel threads to finish, use wait_event()
  to replace wait_event_interruptible().

With this change, the code is more clear, and some potential error
conditions are avoided.

Fixes: 8e7102273f ("bcache: make bch_btree_check() to be multithreaded")
Signed-off-by: Coly Li <colyli@suse.de>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20220524102336.10684-2-colyli@suse.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-05-24 06:19:33 -06:00
..
alloc.c block: decouple REQ_OP_SECURE_ERASE from REQ_OP_DISCARD 2022-04-17 19:49:59 -06:00
bcache.h bcache: move uapi header bcache.h to bcache code directory 2021-10-29 06:43:21 -06:00
bcache_ondisk.h bcache: move uapi header bcache.h to bcache code directory 2021-10-29 06:43:21 -06:00
bset.c bcache: Avoid comma separated statements 2021-02-10 08:06:00 -07:00
bset.h bcache: move uapi header bcache.h to bcache code directory 2021-10-29 06:43:21 -06:00
btree.c bcache: improve multithreaded bch_btree_check() 2022-05-24 06:19:33 -06:00
btree.h bcache: improve multithreaded bch_btree_check() 2022-05-24 06:19:33 -06:00
closure.c bcache: Convert to DEFINE_SHOW_ATTRIBUTE 2020-10-02 14:25:29 -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 block: turn bio_kmalloc into a simple kmalloc wrapper 2022-04-17 19:30:41 -06:00
debug.h bcache: add identifier names to arguments of function definitions 2018-08-11 15:46:41 -06:00
extents.c bcache: remove PTR_CACHE 2021-04-11 08:37:55 -06:00
extents.h bcache: add identifier names to arguments of function definitions 2018-08-11 15:46:41 -06:00
features.c bcache: move uapi header bcache.h to bcache code directory 2021-10-29 06:43:21 -06:00
features.h bcache: move uapi header bcache.h to bcache code directory 2021-10-29 06:43:21 -06:00
io.c block: pass a block_device and opf to bio_init 2022-02-02 07:49:59 -07:00
journal.c block: pass a block_device and opf to bio_reset 2022-02-02 07:50:00 -07:00
journal.h Revert "bcache: fix fifo index swapping condition in journal_pin_cmp()" 2019-11-18 08:35:47 -07:00
Kconfig block: make the block holder code optional 2021-08-09 11:50:42 -06:00
Makefile bcache: add sysfs file to display feature sets information of cache set 2020-07-25 07:38:21 -06:00
movinggc.c block: pass a block_device and opf to bio_init 2022-02-02 07:49:59 -07:00
request.c block: remove QUEUE_FLAG_DISCARD 2022-04-17 19:49:59 -06:00
request.h block: switch polling to be bio based 2021-10-18 06:17:36 -06:00
stats.c bcache: use default_groups in kobj_type 2022-01-26 15:56:18 +01:00
stats.h bcache: remove bcache device self-defined readahead 2021-06-08 15:06:03 -06:00
super.c block: remove QUEUE_FLAG_DISCARD 2022-04-17 19:49:59 -06:00
sysfs.c block: remove QUEUE_FLAG_DISCARD 2022-04-17 19:49:59 -06:00
sysfs.h bcache: use default_groups in kobj_type 2022-01-26 15:56:18 +01: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 treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
util.h for-5.16/bdev-size-2021-10-29 2021-11-01 09:50:37 -07:00
writeback.c bcache: fixup multiple threads crash 2022-03-06 22:33:45 +08:00
writeback.h bcache: consider the fragmentation when update the writeback rate 2021-02-10 08:05:59 -07:00