[PATCH v2 19/26] nbd: Enable lock context analysis

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

Add the missing __must_hold() annotations. Enable lock context analysis in
the Makefile.

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

diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index fe63f3c55d0d..28bb89bc7de3 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -1469,6 +1469,7 @@ static void nbd_config_put(struct nbd_device *nbd)
}

static int nbd_start_device(struct nbd_device *nbd)
+ __must_hold(&nbd->config_lock)
{
struct nbd_config *config = nbd->config;
int num_connections = config->num_connections;
@@ -1541,6 +1542,7 @@ static int nbd_start_device(struct nbd_device *nbd)
}

static int nbd_start_device_ioctl(struct nbd_device *nbd)
+ __must_hold(nbd->config_lock)
{
struct nbd_config *config = nbd->config;
int ret;
@@ -1592,6 +1594,7 @@ static void nbd_set_cmd_timeout(struct nbd_device *nbd, u64 timeout)
/* Must be called with config_lock held */
static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
unsigned int cmd, unsigned long arg)
+ __must_hold(nbd->config_lock)
{
struct nbd_config *config = nbd->config;
loff_t bytesize;