From: Nilay Shroff <nilay@linux.ibm.com>
To: Bart Van Assche <bvanassche@acm.org>, Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org,
Christoph Hellwig <hch@infradead.org>,
Damien Le Moal <dlemoal@kernel.org>,
Marco Elver <elver@google.com>,
Josef Bacik <josef@toxicpanda.com>
Subject: Re: [PATCH v2 05/12] nbd: Enable lock context analysis
Date: Mon, 3 Aug 2026 18:56:41 +0530 [thread overview]
Message-ID: <a438f0ba-e2b0-4fa5-920c-bdbf49769674@linux.ibm.com> (raw)
In-Reply-To: <5e1f54d3826b0d479242a9886ca2c7b6eb8cedaf.1785440858.git.bvanassche@acm.org>
On 7/31/26 1:28 AM, Bart Van Assche wrote:
> Add __must_hold() annotations where these are missing. Document which mutex
> protects nbd_index_idr.
>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
> drivers/block/nbd.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
> index 8f10762e90ef..751449d362b0 100644
> --- a/drivers/block/nbd.c
> +++ b/drivers/block/nbd.c
> @@ -49,8 +49,8 @@
> #define CREATE_TRACE_POINTS
> #include <trace/events/nbd.h>
>
> -static DEFINE_IDR(nbd_index_idr);
> static DEFINE_MUTEX(nbd_index_mutex);
> +static __guarded_by(&nbd_index_mutex) DEFINE_IDR(nbd_index_idr);
Maybe we should replace this with DEFINE_IDR_GUARDED() as I mentioned
in previous email.
> static struct workqueue_struct *nbd_del_wq;
> static int nbd_total_devices = 0;
>
> @@ -1506,6 +1506,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;
> @@ -1578,6 +1579,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;
> @@ -1629,6 +1631,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;
> @@ -2773,7 +2776,11 @@ static void __exit nbd_cleanup(void)
> /* Also wait for nbd_dev_remove_work() completes */
> destroy_workqueue(nbd_del_wq);
>
> - idr_destroy(&nbd_index_idr);
> + {
> + __assume_ctx_lock(&nbd_index_mutex);
> + idr_destroy(&nbd_index_idr);
> + }
> +
Could we instead introduce a scoped __assume_ctx_lock() helper so we don't need the
explicit scope here? Alternatively, would annotating nbd_cleanup() with __context_unsafe
be a better fit?
Thanks,
--Nilay
next prev parent reply other threads:[~2026-08-03 13:26 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-30 19:58 [PATCH v2 00/12] Enable lock context analysis in drivers/block/ Bart Van Assche
2026-07-30 19:58 ` [PATCH v2 01/12] aoe: Enable lock context analysis Bart Van Assche
2026-08-03 12:53 ` Nilay Shroff
2026-08-03 17:24 ` Bart Van Assche
2026-08-04 5:09 ` Nilay Shroff
2026-07-30 19:58 ` [PATCH v2 02/12] loop: Remove the "bool global" function argument Bart Van Assche
2026-08-03 13:05 ` Nilay Shroff
2026-08-03 17:41 ` Bart Van Assche
2026-08-04 6:53 ` Nilay Shroff
2026-07-30 19:58 ` [PATCH v2 03/12] loop: Add lock context annotations Bart Van Assche
2026-08-03 13:11 ` Nilay Shroff
2026-08-03 17:43 ` Bart Van Assche
2026-08-04 7:02 ` Nilay Shroff
2026-07-30 19:58 ` [PATCH v2 04/12] mtip32: Enable lock context analysis Bart Van Assche
2026-08-03 13:16 ` Nilay Shroff
2026-07-30 19:58 ` [PATCH v2 05/12] nbd: " Bart Van Assche
2026-08-03 13:26 ` Nilay Shroff [this message]
2026-08-03 18:03 ` Bart Van Assche
2026-08-04 7:10 ` Nilay Shroff
2026-08-04 9:25 ` Marco Elver
2026-08-04 11:27 ` Nilay Shroff
2026-07-30 19:58 ` [PATCH v2 06/12] null_blk: " Bart Van Assche
2026-08-03 13:35 ` Nilay Shroff
2026-08-03 18:09 ` Bart Van Assche
2026-08-04 7:40 ` Nilay Shroff
2026-07-30 19:58 ` [PATCH v2 07/12] rbd: " Bart Van Assche
2026-08-03 14:03 ` Nilay Shroff
2026-08-03 19:46 ` Bart Van Assche
2026-08-04 10:48 ` Nilay Shroff
2026-08-04 18:24 ` Bart Van Assche
2026-08-06 9:27 ` Marco Elver
2026-07-30 19:58 ` [PATCH v2 08/12] ublk: " Bart Van Assche
2026-07-30 19:58 ` [PATCH v2 09/12] xen-blkback: " Bart Van Assche
2026-07-30 19:58 ` [PATCH v2 10/12] zram: " Bart Van Assche
2026-07-30 19:58 ` [PATCH v2 11/12] rnbd: " Bart Van Assche
2026-07-30 19:58 ` [PATCH v2 12/12] block: Enable lock context analysis for all block drivers Bart Van Assche
2026-08-03 14:22 ` [PATCH v2 00/12] Enable lock context analysis in drivers/block/ Nilay Shroff
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a438f0ba-e2b0-4fa5-920c-bdbf49769674@linux.ibm.com \
--to=nilay@linux.ibm.com \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=dlemoal@kernel.org \
--cc=elver@google.com \
--cc=hch@infradead.org \
--cc=josef@toxicpanda.com \
--cc=linux-block@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox