graph-lock: Fix GRAPH_RDLOCK_GUARD*() to be reader lock

GRAPH_RDLOCK_GUARD() and GRAPH_RDLOCK_GUARD_MAINLOOP() only take a
reader lock for the graph, so the correct annotation for them to use is
TSA_ASSERT_SHARED rather than TSA_ASSERT.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20230504115750.54437-8-kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
Kevin Wolf 2023-05-04 13:57:37 +02:00
parent d51c349b64
commit 4ee1f854ec

View File

@ -205,12 +205,12 @@ typedef struct GraphLockable { } GraphLockable;
#define GML_OBJ_() (&(GraphLockable) { }) #define GML_OBJ_() (&(GraphLockable) { })
/* /*
* This is not marked as TSA_ACQUIRE() because TSA doesn't understand the * This is not marked as TSA_ACQUIRE_SHARED() because TSA doesn't understand the
* cleanup attribute and would therefore complain that the graph is never * cleanup attribute and would therefore complain that the graph is never
* unlocked. TSA_ASSERT() makes sure that the following calls know that we * unlocked. TSA_ASSERT_SHARED() makes sure that the following calls know that
* hold the lock while unlocking is left unchecked. * we hold the lock while unlocking is left unchecked.
*/ */
static inline GraphLockable * TSA_ASSERT(graph_lock) TSA_NO_TSA coroutine_fn static inline GraphLockable * TSA_ASSERT_SHARED(graph_lock) TSA_NO_TSA coroutine_fn
graph_lockable_auto_lock(GraphLockable *x) graph_lockable_auto_lock(GraphLockable *x)
{ {
bdrv_graph_co_rdlock(); bdrv_graph_co_rdlock();
@ -249,12 +249,12 @@ typedef struct GraphLockableMainloop { } GraphLockableMainloop;
#define GMLML_OBJ_() (&(GraphLockableMainloop) { }) #define GMLML_OBJ_() (&(GraphLockableMainloop) { })
/* /*
* This is not marked as TSA_ACQUIRE() because TSA doesn't understand the * This is not marked as TSA_ACQUIRE_SHARED() because TSA doesn't understand the
* cleanup attribute and would therefore complain that the graph is never * cleanup attribute and would therefore complain that the graph is never
* unlocked. TSA_ASSERT() makes sure that the following calls know that we * unlocked. TSA_ASSERT_SHARED() makes sure that the following calls know that
* hold the lock while unlocking is left unchecked. * we hold the lock while unlocking is left unchecked.
*/ */
static inline GraphLockableMainloop * TSA_ASSERT(graph_lock) TSA_NO_TSA static inline GraphLockableMainloop * TSA_ASSERT_SHARED(graph_lock) TSA_NO_TSA
graph_lockable_auto_lock_mainloop(GraphLockableMainloop *x) graph_lockable_auto_lock_mainloop(GraphLockableMainloop *x)
{ {
bdrv_graph_rdlock_main_loop(); bdrv_graph_rdlock_main_loop();