lvm2/0010-lvmlockd-client-mutex-ordering.patch

41 lines
1.1 KiB
Diff

From cd17ccbc684590e8655888af6d6b0452287fd47d Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Thu, 31 Aug 2023 13:15:07 -0500
Subject: [PATCH 10/24] lvmlockd: client mutex ordering
Avoid deadlock between threads on mutexes (in theory.)
---
daemons/lvmlockd/lvmlockd-core.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/daemons/lvmlockd/lvmlockd-core.c b/daemons/lvmlockd/lvmlockd-core.c
index 887226f1a..1261f6482 100644
--- a/daemons/lvmlockd/lvmlockd-core.c
+++ b/daemons/lvmlockd/lvmlockd-core.c
@@ -4690,9 +4690,12 @@ static int dump_info(int *dump_len)
/*
* clients
+ * Proper lock order is client_mutex then cl->mutex,
+ * but cl->mutex is already held so skip client info
+ * if it would block.
*/
-
- pthread_mutex_lock(&client_mutex);
+ if (pthread_mutex_trylock(&client_mutex))
+ goto print_ls;
list_for_each_entry(cl, &client_list, list) {
ret = print_client(cl, "client", pos, len);
if (ret >= len - pos) {
@@ -4706,6 +4709,7 @@ static int dump_info(int *dump_len)
if (rv < 0)
return rv;
+ print_ls:
/*
* lockspaces with their action/resource/lock info
*/
--
2.35.3