Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
graph-lock: Add GRAPH_UNLOCKED(_PTR)
For some functions, it is part of their interface to be called without
holding the graph lock. Add a new macro to document this.

The macro expands to TSA_EXCLUDES(), which is a relatively weak check
because it passes in cases where the compiler just doesn't know if the
lock is held. Function pointers can't be checked at all. Therefore, its
primary purpose is documentation.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20230504115750.54437-7-kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
  • Loading branch information
Kevin Wolf committed May 10, 2023
1 parent 57f3d07 commit d51c349
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/block/graph-lock.h
Expand Up @@ -73,6 +73,7 @@ extern BdrvGraphLock graph_lock;
*/
#define GRAPH_WRLOCK TSA_REQUIRES(graph_lock)
#define GRAPH_RDLOCK TSA_REQUIRES_SHARED(graph_lock)
#define GRAPH_UNLOCKED TSA_EXCLUDES(graph_lock)

/*
* TSA annotations are not part of function types, so checks are defeated when
Expand All @@ -83,6 +84,7 @@ extern BdrvGraphLock graph_lock;
*/
#define GRAPH_RDLOCK_PTR TSA_GUARDED_BY(graph_lock)
#define GRAPH_WRLOCK_PTR TSA_GUARDED_BY(graph_lock)
#define GRAPH_UNLOCKED_PTR

/*
* register_aiocontext:
Expand Down

0 comments on commit d51c349

Please sign in to comment.