* [PATCH v1] bcache: fix AB-BA deadlock between cache register and cache_set_free
@ 2022-03-29 3:17 daihuaigang129
2022-04-07 16:30 ` Coly Li
0 siblings, 1 reply; 2+ messages in thread
From: daihuaigang129 @ 2022-03-29 3:17 UTC (permalink / raw)
To: colyli, kent.overstreet; +Cc: linux-bcache, linux-kernel, daihuaigang
From: daihuaigang <daihuaigang129@163.com>
bcache register add kobject_mutex then bch_register_mutex,
cache_set_free add bch_register_mutex then kobject_mutex.
fix AB-BA deadlock between cache register and cache_set_free.
Signed-off-by: daihuaigang <daihuaigang129@163.com>
---
drivers/md/bcache/super.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index bf3de14..f17953c 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -1690,10 +1690,8 @@ static void cache_set_free(struct closure *cl)
if (ca) {
ca->set = NULL;
c->cache = NULL;
- kobject_put(&ca->kobj);
}
-
if (c->moving_gc_wq)
destroy_workqueue(c->moving_gc_wq);
bioset_exit(&c->bio_split);
@@ -1704,6 +1702,8 @@ static void cache_set_free(struct closure *cl)
list_del(&c->list);
mutex_unlock(&bch_register_lock);
+ if (ca)
+ kobject_put(&ca->kobj);
pr_info("Cache set %pU unregistered\n", c->set_uuid);
wake_up(&unregister_wait);
--
1.8.3.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v1] bcache: fix AB-BA deadlock between cache register and cache_set_free
2022-03-29 3:17 [PATCH v1] bcache: fix AB-BA deadlock between cache register and cache_set_free daihuaigang129
@ 2022-04-07 16:30 ` Coly Li
0 siblings, 0 replies; 2+ messages in thread
From: Coly Li @ 2022-04-07 16:30 UTC (permalink / raw)
To: daihuaigang129; +Cc: linux-bcache, kent.overstreet, linux-kernel
On 3/29/22 11:17 AM, daihuaigang129@163.com wrote:
> From: daihuaigang <daihuaigang129@163.com>
>
> bcache register add kobject_mutex then bch_register_mutex,
> cache_set_free add bch_register_mutex then kobject_mutex.
> fix AB-BA deadlock between cache register and cache_set_free.
Can you explain a bit more about,
- For "bcache register add kobject_mutex", which function referred by
"bcache register add", and where is the kobject_mutex.
- Where is bch_regsiter_mutex.
It is not clear for me to understand how hte AB-BA deadlock generated yet.
Thanks.
Coly Li
>
> Signed-off-by: daihuaigang <daihuaigang129@163.com>
> ---
> drivers/md/bcache/super.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
> index bf3de14..f17953c 100644
> --- a/drivers/md/bcache/super.c
> +++ b/drivers/md/bcache/super.c
> @@ -1690,10 +1690,8 @@ static void cache_set_free(struct closure *cl)
> if (ca) {
> ca->set = NULL;
> c->cache = NULL;
> - kobject_put(&ca->kobj);
> }
>
> -
> if (c->moving_gc_wq)
> destroy_workqueue(c->moving_gc_wq);
> bioset_exit(&c->bio_split);
> @@ -1704,6 +1702,8 @@ static void cache_set_free(struct closure *cl)
>
> list_del(&c->list);
> mutex_unlock(&bch_register_lock);
> + if (ca)
> + kobject_put(&ca->kobj);
>
> pr_info("Cache set %pU unregistered\n", c->set_uuid);
> wake_up(&unregister_wait);
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-04-07 16:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-29 3:17 [PATCH v1] bcache: fix AB-BA deadlock between cache register and cache_set_free daihuaigang129
2022-04-07 16:30 ` Coly Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).