linux-uconsole/drivers/md/bcache
Mingzhe Zou 8dde2296ec bcache: fixup multiple threads crash
commit 887554ab96 upstream.

When multiple threads to check btree nodes in parallel, the main
thread wait for all threads to stop or CACHE_SET_IO_DISABLE flag:

wait_event_interruptible(check_state->wait,
                         atomic_read(&check_state->started) == 0 ||
                         test_bit(CACHE_SET_IO_DISABLE, &c->flags));

However, the bch_btree_node_read and bch_btree_node_read_done
maybe call bch_cache_set_error, then the CACHE_SET_IO_DISABLE
will be set. If the flag already set, the main thread return
error. At the same time, maybe some threads still running and
read NULL pointer, the kernel will crash.

This patch change the event wait condition, the main thread must
wait for all threads to stop.

Fixes: 8e7102273f ("bcache: make bch_btree_check() to be multithreaded")
Signed-off-by: Mingzhe Zou <mingzhe.zou@easystack.cn>
Cc: stable@vger.kernel.org # v5.7+
Signed-off-by: Coly Li <colyli@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-04-08 14:39:57 +02:00
..
alloc.c
bcache.h bcache: Move journal work to new flush wq 2021-03-04 11:38:26 +01:00
bset.c
bset.h
btree.c bcache: fixup multiple threads crash 2022-04-08 14:39:57 +02:00
btree.h
closure.c
closure.h
debug.c
debug.h
extents.c
extents.h
features.c bcache: introduce BCH_FEATURE_INCOMPAT_LOG_LARGE_BUCKET_SIZE for large bucket 2021-01-12 20:18:25 +01:00
features.h bcache: only check feature sets when sb->version >= BCACHE_SB_VERSION_CDEV_WITH_FEATURES 2021-02-03 23:28:39 +01:00
io.c
journal.c bcache: Move journal work to new flush wq 2021-03-04 11:38:26 +01:00
journal.h
Kconfig
Makefile
movinggc.c
request.c
request.h
stats.c
stats.h
super.c bcache: add proper error unwinding in bcache_device_init 2021-09-15 09:50:25 +02:00
sysfs.c
sysfs.h
trace.c
util.c
util.h
writeback.c bcache: fixup multiple threads crash 2022-04-08 14:39:57 +02:00
writeback.h