[PATCH v2 17/26] loop: Add lock context annotations

Bart Van Assche
2026-03-25T21:46:16Z

Add lock context annotations that are compatible with Clang and enable
lock context analysis.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/block/loop.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 0000913f7efc..9c7ed9e8a442 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -107,6 +107,8 @@ static DEFINE_MUTEX(loop_validate_mutex);
* loop_configure()/loop_change_fd()/__loop_clr_fd() calls.
*/
static int loop_global_lock_killable(struct loop_device *lo, bool global)
+ __cond_acquires(0, &lo->lo_mutex)
+ __no_context_analysis /* conditional locking */
{
int err;

@@ -128,6 +130,8 @@ static int loop_global_lock_killable(struct loop_device *lo, bool global)
* @global: true if @lo was about to bind another "struct loop_device", false otherwise
*/
static void loop_global_unlock(struct loop_device *lo, bool global)
+ __releases(&lo->lo_mutex)
+ __no_context_analysis /* conditional locking */
{
mutex_unlock(&lo->lo_mutex);
if (global)