The root cause: After just cached_dev_free do cancel_writeback_rate_update_dwork without bch_register_lock . at the same time. Wirting the writeback_percent by sysfs witch bch_register_lock will insert a writeback_rate_update work.
cached_dev_free with bch_register_lock to do bcache_device_free. (it is introduce by patch 80265d8dfd77792e133793cef44a21323aac2908) pls: 1: run the shell script #!/bin/bash while [ true ] do echo 0 > /sys/block/bcache0/bcache/writeback_percent done 2: hotplug the cache disk On 12/3/20, Coly Li <col...@suse.de> wrote: > On 12/3/20 2:25 PM, Yi Li wrote: >>> On 12/1/20 12:35 PM, Yi Li wrote: >>>> sorry, This patch will cause deadlock, i will check and redo it. >>> >>> Can you try latest upstream kernel firstly ? Before spending more time >>> on the fix. >>> >> >> This issue just happened three times (xenserver7.5 dom0 kernel) on the >> same machine and cannot reproduce it now. and have not reproduce it >> using the lastest uptream kernel. >> > > Hmm, this is something very probably that I am not able to help. It > seems the kernel is a third-part maintained Linux v4.4 based kernel + > bcache backport, which is out of my view. > > If similar problem happens on latest upstream kernel, or at least v5.8+ > kernel, I can help to take a look. > > >>> If I remember correctly, when cancel_writeback_rate_update_dwork() is >>> not timed out, the cache set memory won't be freed before the >>> writeback_rate_update worker terminates. It is possible that I miss >>> something in the code, but I suggest to test with a kernel after v5.3, >>> and better a v5.8+ kernel. >>> >>> Coly Li >>> >> Thanks. >> >> it is confused that why writeback_rate_update worker run again after >> cancel_delayed_work_sync( kernel log telled). >> > > [snipped] > > Coly Li >