Linux block layer
 help / color / mirror / Atom feed
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>, Ilya Dryomov <idryomov@gmail.com>
Subject: Re: [PATCH v2 07/12] rbd: Enable lock context analysis
Date: Mon, 3 Aug 2026 19:33:56 +0530	[thread overview]
Message-ID: <487841d2-9d55-4873-ab6b-dbd94aa7bb71@linux.ibm.com> (raw)
In-Reply-To: <0b2988ca05e8a2733352a447e0810104b878376a.1785440858.git.bvanassche@acm.org>

On 7/31/26 1:28 AM, Bart Van Assche wrote:
> Add lock context annotations.
> 
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>   drivers/block/rbd.c | 8 ++++++++
>   1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
> index 1f1c2810f6ee..f0f7a94e3e3e 100644
> --- a/drivers/block/rbd.c
> +++ b/drivers/block/rbd.c
> @@ -4183,6 +4183,7 @@ static void rbd_acquire_lock(struct work_struct *work)
>   }
>   
>   static bool rbd_quiesce_lock(struct rbd_device *rbd_dev)
> +	__must_hold(&rbd_dev->lock_rwsem)
>   {
>   	dout("%s rbd_dev %p\n", __func__, rbd_dev);
>   	lockdep_assert_held_write(&rbd_dev->lock_rwsem);
> @@ -4227,6 +4228,7 @@ static void __rbd_release_lock(struct rbd_device *rbd_dev)
>    * lock_rwsem must be held for write
>    */
>   static void rbd_release_lock(struct rbd_device *rbd_dev)
> +	__must_hold(&rbd_dev->lock_rwsem)
>   {
>   	if (!rbd_quiesce_lock(rbd_dev))
>   		return;
> @@ -4583,6 +4585,7 @@ static void rbd_unregister_watch(struct rbd_device *rbd_dev)
>    * lock_rwsem must be held for write
>    */
>   static void rbd_reacquire_lock(struct rbd_device *rbd_dev)
> +	__must_hold(&rbd_dev->lock_rwsem)
>   {
>   	struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc;
>   	char cookie[32];
> @@ -6780,6 +6783,7 @@ static void rbd_dev_device_release(struct rbd_device *rbd_dev)
>    * upon return.
>    */
>   static int rbd_dev_device_setup(struct rbd_device *rbd_dev)
> +	__releases(&rbd_dev->header_rwsem)
>   {
>   	int ret;
>   
> @@ -6881,6 +6885,7 @@ static void rbd_dev_image_release(struct rbd_device *rbd_dev)
>    * with @depth == 0.
>    */
>   static int rbd_dev_image_probe(struct rbd_device *rbd_dev, int depth)
> +	__context_unsafe(conditional locking on @depth)
>   {
>   	bool need_watch = !rbd_is_ro(rbd_dev);
>   	int ret;
> @@ -7134,6 +7139,9 @@ static ssize_t do_rbd_add(const char *buf, size_t count)
>   	if (rc < 0)
>   		goto err_out_rbd_dev;
>   
> +	/* Acquired by rbd_dev_image_probe(rbd_dev, 0) */
> +	__acquire(&rbd_dev->header_rwsem);
> +
>   	if (rbd_dev->opts->alloc_size > rbd_dev->layout.object_size) {
>   		rbd_warn(rbd_dev, "alloc_size adjusted to %u",
>   			 rbd_dev->layout.object_size);


In addition to the above annotations, it looks like several variables and structure members
are consistently protected by specific locks:

1. rbd_dev_list is guarded by rbd_dev_list_lock.
2. rbd_client_list is guarded by rbd_client_list_lock.
3. rbd_device::acquiring_list and rbd_device::running_list are guarded by
    rbd_device::lock_lists_lock.
4. rbd_device::object_map is guarded by rbd_device::object_map_lock.
5. rbd_device::watch_cookie, rbd_device::watch_state, and rbd_device::watch_handle
    are guarded by rbd_device::watch_mutex.
6. rbd_device::lock_state and rbd_device::lock_cookie are guarded by rbd_device::lock_rwsem.

So I think we should add the corresponding `__guarded_by(...)` annotations for these
fields as part of enabling lock context analysis for this driver.

Thanks,
--Nilay


  reply	other threads:[~2026-08-03 14:04 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
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 [this message]
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=487841d2-9d55-4873-ab6b-dbd94aa7bb71@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=idryomov@gmail.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