From: Christoph Hellwig <hch@lst.de>
To: Bart Van Assche <bvanassche@acm.org>
Cc: "Jens Axboe" <axboe@kernel.dk>,
linux-block@vger.kernel.org, "Christoph Hellwig" <hch@lst.de>,
"Damien Le Moal" <dlemoal@kernel.org>,
"Tejun Heo" <tj@kernel.org>,
"Christoph Böhmwalder" <christoph.boehmwalder@linbit.com>,
"Philipp Reisner" <philipp.reisner@linbit.com>,
"Lars Ellenberg" <lars.ellenberg@linbit.com>,
"Nathan Chancellor" <nathan@kernel.org>
Subject: Re: [PATCH v2 16/26] drbd: Make the lock context annotations compatible with Clang
Date: Thu, 26 Mar 2026 15:18:14 +0100 [thread overview]
Message-ID: <20260326141814.GC16166@lst.de> (raw)
In-Reply-To: <20260325214518.2854494-17-bvanassche@acm.org>
On Wed, Mar 25, 2026 at 02:44:57PM -0700, Bart Van Assche wrote:
> Clang performs more strict checking of lock context annotations than
> sparse. This patch makes the DRBD lock context annotations compatible
> with Clang and enables lock context analysis in the Makefile.
>
> Reviewed-by: Christoph Böhmwalder <christoph.boehmwalder@linbit.com>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
> drivers/block/drbd/Makefile | 3 +
> drivers/block/drbd/drbd_bitmap.c | 26 ++++++---
> drivers/block/drbd/drbd_int.h | 88 ++++++++++++++++++------------
> drivers/block/drbd/drbd_main.c | 40 ++++++++++----
> drivers/block/drbd/drbd_nl.c | 5 +-
> drivers/block/drbd/drbd_receiver.c | 31 ++++++++---
> drivers/block/drbd/drbd_req.c | 3 +
> drivers/block/drbd/drbd_state.c | 2 +
> drivers/block/drbd/drbd_state.h | 4 --
> drivers/block/drbd/drbd_worker.c | 6 +-
> 10 files changed, 138 insertions(+), 70 deletions(-)
>
> diff --git a/drivers/block/drbd/Makefile b/drivers/block/drbd/Makefile
> index 67a8b352a1d5..8eaa83a7592b 100644
> --- a/drivers/block/drbd/Makefile
> +++ b/drivers/block/drbd/Makefile
> @@ -1,4 +1,7 @@
> # SPDX-License-Identifier: GPL-2.0-only
> +
> +CONTEXT_ANALYSIS := y
> +
> drbd-y := drbd_buildtag.o drbd_bitmap.o drbd_proc.o
> drbd-y += drbd_worker.o drbd_receiver.o drbd_req.o drbd_actlog.o
> drbd-y += drbd_main.o drbd_strings.o drbd_nl.o
> diff --git a/drivers/block/drbd/drbd_bitmap.c b/drivers/block/drbd/drbd_bitmap.c
> index 65ea6ec66bfd..3c521f0dc9ad 100644
> --- a/drivers/block/drbd/drbd_bitmap.c
> +++ b/drivers/block/drbd/drbd_bitmap.c
> @@ -122,12 +122,16 @@ static void __bm_print_lock_info(struct drbd_device *device, const char *func)
> }
>
> void drbd_bm_lock(struct drbd_device *device, char *why, enum bm_flag flags)
> + __acquires(&device->bitmap->bm_change)
> {
> struct drbd_bitmap *b = device->bitmap;
> int trylock_failed;
>
> if (!b) {
> drbd_err(device, "FIXME no bitmap in drbd_bm_lock!?\n");
> + /* Fake __acquire() to keep the compiler happy. */
> + __acquire(&b->bm_change);
> + __acquire(drbd_bitmap_lock);
> return;
This looks like an impossible to hit case with cargo cult code. I'd
suggest to remove it instead.
Similarly please kill the trylock_faiuled code, which has weird
debugging that is strictly inferior to what lockdep already provides.
> void drbd_bm_unlock(struct drbd_device *device)
> + __releases(&device->bitmap->bm_change)
> {
> struct drbd_bitmap *b = device->bitmap;
> if (!b) {
> drbd_err(device, "FIXME no bitmap in drbd_bm_unlock!?\n");
> + /* Fake __release() to keep the compiler happy. */
> + __release(&b->bm_change);
> + __release(drbd_bitmap_lock);
> return;
> }
Same comment as above.
> +extern void drbd_uuid_set(struct drbd_device *device, int idx, u64 val);
> +extern void _drbd_uuid_set(struct drbd_device *device, int idx, u64 val);
> +extern void drbd_uuid_new_current(struct drbd_device *device);
> +extern void drbd_uuid_set_bm(struct drbd_device *device, u64 val);
> +extern void drbd_uuid_move_history(struct drbd_device *device);
> +extern void __drbd_uuid_set(struct drbd_device *device, int idx, u64 val);
> +extern void drbd_md_set_flag(struct drbd_device *device, int flags);
> +extern void drbd_md_clear_flag(struct drbd_device *device, int flags);
All these externs should go away.
In general this still mixes up way too many things. Address one
lock/issue at a time, and write proper commit logs explain why a
given solution is taken.
next prev parent reply other threads:[~2026-03-26 14:18 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-25 21:44 [PATCH v2 00/26] Enable lock context analysis Bart Van Assche
2026-03-25 21:44 ` [PATCH v2 01/26] block: Annotate the queue limits functions Bart Van Assche
2026-03-26 6:23 ` Christoph Hellwig
2026-03-25 21:44 ` [PATCH v2 02/26] block: Annotate the block device functions Bart Van Assche
2026-03-26 6:25 ` Christoph Hellwig
2026-03-26 15:55 ` Bart Van Assche
2026-03-27 18:17 ` Marco Elver
2026-03-27 18:27 ` Bart Van Assche
2026-03-25 21:44 ` [PATCH v2 03/26] block/cgroup: Split blkg_conf_prep() Bart Van Assche
2026-03-26 6:25 ` Christoph Hellwig
2026-03-25 21:44 ` [PATCH v2 04/26] block/cgroup: Split blkg_conf_exit() Bart Van Assche
2026-03-26 6:26 ` Christoph Hellwig
2026-03-25 21:44 ` [PATCH v2 05/26] block/cgroup: Modify the blkg_conf_open_bdev_frozen() calling convention Bart Van Assche
2026-03-26 6:28 ` Christoph Hellwig
2026-03-25 21:44 ` [PATCH v2 06/26] block/crypto: Annotate the crypto functions Bart Van Assche
2026-03-26 6:28 ` Christoph Hellwig
2026-03-25 21:44 ` [PATCH v2 07/26] block/blk-iocost: Add lock context annotations Bart Van Assche
2026-03-26 6:31 ` Christoph Hellwig
2026-03-25 21:44 ` [PATCH v2 08/26] block/blk-mq-debugfs: Improve " Bart Van Assche
2026-03-26 6:32 ` Christoph Hellwig
2026-03-25 21:44 ` [PATCH v2 09/26] block/blk-zoned: Add " Bart Van Assche
2026-03-26 6:42 ` Christoph Hellwig
2026-03-25 21:44 ` [PATCH v2 10/26] block/ioctl: " Bart Van Assche
2026-03-26 6:39 ` Christoph Hellwig
2026-03-25 21:44 ` [PATCH v2 11/26] block/Kyber: Make the lock context annotations compatible with Clang Bart Van Assche
2026-03-26 6:40 ` Christoph Hellwig
2026-03-25 21:44 ` [PATCH v2 12/26] block/mq-deadline: " Bart Van Assche
2026-03-25 21:44 ` [PATCH v2 13/26] block: Enable lock context analysis Bart Van Assche
2026-03-25 21:44 ` [PATCH v2 14/26] aoe: Add a lock context annotation Bart Van Assche
2026-03-26 14:13 ` Christoph Hellwig
2026-03-25 21:44 ` [PATCH v2 15/26] drbd: Balance RCU calls in drbd_adm_dump_devices() Bart Van Assche
2026-03-26 14:14 ` Christoph Hellwig
2026-03-25 21:44 ` [PATCH v2 16/26] drbd: Make the lock context annotations compatible with Clang Bart Van Assche
2026-03-26 14:18 ` Christoph Hellwig [this message]
2026-03-25 21:44 ` [PATCH v2 17/26] loop: Add lock context annotations Bart Van Assche
2026-03-26 14:18 ` Christoph Hellwig
2026-03-25 21:44 ` [PATCH v2 18/26] mtip32: Enable lock context analysis Bart Van Assche
2026-03-26 14:18 ` Christoph Hellwig
2026-03-25 21:45 ` [PATCH v2 19/26] nbd: " Bart Van Assche
2026-03-26 14:18 ` Christoph Hellwig
2026-03-25 21:45 ` [PATCH v2 20/26] null_blk: " Bart Van Assche
2026-03-26 14:19 ` Christoph Hellwig
2026-03-25 21:45 ` [PATCH v2 21/26] rbd: " Bart Van Assche
2026-03-25 21:45 ` [PATCH v2 22/26] ublk: " Bart Van Assche
2026-03-25 21:45 ` [PATCH v2 23/26] xen-blkback: " Bart Van Assche
2026-03-26 9:25 ` Roger Pau Monné
2026-03-25 21:45 ` [PATCH v2 24/26] zram: " Bart Van Assche
2026-03-25 21:45 ` [PATCH v2 25/26] rnbd: " Bart Van Assche
2026-03-26 6:58 ` Jinpu Wang
2026-03-25 21:45 ` [PATCH v2 26/26] block: Enable lock context analysis for all block drivers Bart Van Assche
2026-03-26 6:23 ` [PATCH v2 00/26] Enable lock context analysis Christoph Hellwig
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=20260326141814.GC16166@lst.de \
--to=hch@lst.de \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=christoph.boehmwalder@linbit.com \
--cc=dlemoal@kernel.org \
--cc=lars.ellenberg@linbit.com \
--cc=linux-block@vger.kernel.org \
--cc=nathan@kernel.org \
--cc=philipp.reisner@linbit.com \
--cc=tj@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