]> sourceware.org Git - lvm2.git/commitdiff
lvmlockd: client mutex ordering 988258448
authorDavid Teigland <teigland@redhat.com>
Thu, 31 Aug 2023 18:15:07 +0000 (13:15 -0500)
committerDavid Teigland <teigland@redhat.com>
Thu, 31 Aug 2023 18:15:07 +0000 (13:15 -0500)
Avoid deadlock between threads on mutexes (in theory.)

daemons/lvmlockd/lvmlockd-core.c

index 887226f1a74292464303bff4bde2ef1d0ab553ad..1261f648205dbad5fa962bd6107a8251b8fe19f9 100644 (file)
@@ -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
         */
This page took 0.039578 seconds and 5 git commands to generate.