]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
bcache: fix a lost wake-up problem caused by mca_cannibalize_lock
authorGuoju Fang <fangguoju@gmail.com>
Wed, 13 Nov 2019 08:03:16 +0000 (16:03 +0800)
committerJens Axboe <axboe@kernel.dk>
Wed, 13 Nov 2019 22:42:50 +0000 (15:42 -0700)
commit34cf78bf34d48dddddfeeadb44f9841d7864997a
treed6010b3ea9defa5300f679f4fe8bd55d85ebd2bd
parentc0e0954e909c17b43d176ab219fc598964616ae6
bcache: fix a lost wake-up problem caused by mca_cannibalize_lock

This patch fix a lost wake-up problem caused by the race between
mca_cannibalize_lock and bch_cannibalize_unlock.

Consider two processes, A and B. Process A is executing
mca_cannibalize_lock, while process B takes c->btree_cache_alloc_lock
and is executing bch_cannibalize_unlock. The problem happens that after
process A executes cmpxchg and will execute prepare_to_wait. In this
timeslice process B executes wake_up, but after that process A executes
prepare_to_wait and set the state to TASK_INTERRUPTIBLE. Then process A
goes to sleep but no one will wake up it. This problem may cause bcache
device to dead.

Signed-off-by: Guoju Fang <fangguoju@gmail.com>
Signed-off-by: Coly Li <colyli@suse.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/md/bcache/bcache.h
drivers/md/bcache/btree.c
drivers/md/bcache/super.c