Skip to content

Enable lock context analysis in drivers/block/#947

Open
blktests-ci[bot] wants to merge 27 commits into
for-next_basefrom
series/1108850=>for-next
Open

Enable lock context analysis in drivers/block/#947
blktests-ci[bot] wants to merge 27 commits into
for-next_basefrom
series/1108850=>for-next

Conversation

@blktests-ci

@blktests-ci blktests-ci Bot commented Jun 9, 2026

Copy link
Copy Markdown

Pull request for series with
subject: Enable lock context analysis in drivers/block/
version: 1
url: https://patchwork.kernel.org/project/linux-block/list/?series=1108850

@blktests-ci

blktests-ci Bot commented Jun 9, 2026

Copy link
Copy Markdown
Author

Upstream branch: 8b87d2b
series: https://patchwork.kernel.org/project/linux-block/list/?series=1108850
version: 1

@blktests-ci

blktests-ci Bot commented Jun 10, 2026

Copy link
Copy Markdown
Author

Upstream branch: 8b87d2b
series: https://patchwork.kernel.org/project/linux-block/list/?series=1108850
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/1108850=>for-next branch from d431b82 to 55a36ea Compare June 10, 2026 00:11
@blktests-ci

blktests-ci Bot commented Jun 10, 2026

Copy link
Copy Markdown
Author

Upstream branch: 8b87d2b
series: https://patchwork.kernel.org/project/linux-block/list/?series=1108850
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/1108850=>for-next branch from 55a36ea to d772389 Compare June 10, 2026 03:08
@blktests-ci

blktests-ci Bot commented Jun 10, 2026

Copy link
Copy Markdown
Author

Upstream branch: 8b87d2b
series: https://patchwork.kernel.org/project/linux-block/list/?series=1108850
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/1108850=>for-next branch from d772389 to d1a7988 Compare June 10, 2026 05:49
@blktests-ci

blktests-ci Bot commented Jun 10, 2026

Copy link
Copy Markdown
Author

Upstream branch: 8b87d2b
series: https://patchwork.kernel.org/project/linux-block/list/?series=1108850
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/1108850=>for-next branch from d1a7988 to 28a8671 Compare June 10, 2026 07:39
@blktests-ci

blktests-ci Bot commented Jun 10, 2026

Copy link
Copy Markdown
Author

Upstream branch: 8282f98
series: https://patchwork.kernel.org/project/linux-block/list/?series=1108850
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/1108850=>for-next branch from 28a8671 to d46f60a Compare June 10, 2026 13:54
@blktests-ci

blktests-ci Bot commented Jun 12, 2026

Copy link
Copy Markdown
Author

Upstream branch: 8282f98
series: https://patchwork.kernel.org/project/linux-block/list/?series=1108850
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/1108850=>for-next branch from d46f60a to 56d19d2 Compare June 12, 2026 15:13
@blktests-ci

blktests-ci Bot commented Jun 12, 2026

Copy link
Copy Markdown
Author

Upstream branch: 1d1de89
series: https://patchwork.kernel.org/project/linux-block/list/?series=1108850
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/1108850=>for-next branch from 56d19d2 to 1253071 Compare June 12, 2026 22:49
@blktests-ci

blktests-ci Bot commented Jun 17, 2026

Copy link
Copy Markdown
Author

Upstream branch: 5c7804e
series: https://patchwork.kernel.org/project/linux-block/list/?series=1108850
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/1108850=>for-next branch from 1253071 to 8181c0d Compare June 17, 2026 12:48
@blktests-ci

blktests-ci Bot commented Jun 24, 2026

Copy link
Copy Markdown
Author

Upstream branch: b9e3062
series: https://patchwork.kernel.org/project/linux-block/list/?series=1108850
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/1108850=>for-next branch from 8181c0d to 55f441f Compare June 24, 2026 01:26
@blktests-ci

blktests-ci Bot commented Jun 26, 2026

Copy link
Copy Markdown
Author

Upstream branch: 523fc0d
series: https://patchwork.kernel.org/project/linux-block/list/?series=1108850
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/1108850=>for-next branch from 55f441f to d224906 Compare June 26, 2026 08:45
bvanassche added 24 commits July 7, 2026 08:55
Add a missing __must_hold() annotation. Enable lock context analysis in the
Makefile.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Md Haris Iqbal <haris.iqbal@linux.dev>
The "extern" keyword is superfluous when declaring a function. Remove
that keyword from function definitions to improve consistency with the
rest of the kernel source code.

Suggested-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
There are two slightly different _get_ldev_if_state() implementations
in the DRBD source code. Keep the version that is used. This does not
affect C=1 / C=2 builds because lock context checking is performed by
Clang instead of sparse since commit 5b63d0a ("compiler-context-
analysis: Remove Sparse support").

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
The get_ldev_if_state() macro has been introduced because sparse does
not support something like __cond_acquires(). Remove this macro and
rename _get_ldev_if_state() into get_ldev_if_state().

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
The 'local' lock context represents code sections between get_ldev() and
put_ldev() calls. Between these two calls the device->ldev pointer is
valid. Since there are multiple functions with unpaired get_ldev() /
put_ldev() calls, remove this lock context.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Call mutex_lock() instead of mutex_trylock() followed by mutex_lock().
Remove the code that depends on device->bitmap == NULL because this
can't happen. All drbd_bm_{lock,unlock}() callers guarantee that the
device->bitmap pointer is valid.

Suggested-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Move the resources_mutex declaration in front of the functions that
acquire and release this mutex. Move the drbd_wait_misc() declaration
past the struct drbd_device definition. This patch prepares for adding
lock context annotations.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Prepare for adding lock context annotations. Without this change, an
__assume_ctx_lock() statement would have to be added.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Move the code between the 'put_result' and 'out' labels into a new
function. Prepare for making the following code unconditional:

	if (resource)
		mutex_unlock(&resource->conf_update);

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Only jump to the 'out' label if resource is not NULL such that the
mutex_unlock() call past the 'out' label can be made unconditional.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Move all code except a mutex_lock() and a mutex_unlock() call from
drbd_req_state() into the new function __drbd_req_state(). This patch
prepares for adding a second __drbd_req_state() caller.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Prepare for enabling lock context analysis.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Annotate the bitmap locking functions. Introduce a new token context
lock because the struct drbd_device definition is not visible from the
drbd_int.h header file. Annotate the declarations of bitmap locking
functions with only the token context lock. Annotate the definitions of
the bitmap locking functions with both the token context lock and the
actual mutex.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
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.

Cc: Christoph Böhmwalder <christoph.boehmwalder@linbit.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Prepare for adding a second call of __loop_change_fd().

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Prepare for adding a second __loop_configure() call.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Keep the behavior in loop_global_lock_killable() for the global == true
case. Expand loop_global_lock_killable(lo, false) calls into a
mutex_lock_killable() and a mutex_unlock() call.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Add lock context annotations that are compatible with Clang.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Let the compiler verify lock and unlock calls. Enable lock context analysis
in the Makefile.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Add the missing __must_hold() annotations. Enable lock context analysis in
the Makefile.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Add __must_hold() annotations where these are missing. Annotate two
functions that use conditional locking with __context_unsafe(). Enable lock
context analysis in the Makefile.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Nilay Shroff <nilay@linux.ibm.com>
Add lock context annotations and enable lock context analysis.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Add the lock context annotations that are required by Clang.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Ming Lei <tom.leiming@gmail.com>
Let Clang verify lock and unlock calls. Enable lock context analysis in the
Makefile.

Acked-by: Roger Pau Monné <roger.pau@citrix.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
@blktests-ci

blktests-ci Bot commented Jul 7, 2026

Copy link
Copy Markdown
Author

Upstream branch: 54740e4
series: https://patchwork.kernel.org/project/linux-block/list/?series=1108850
version: 1

Add the lock context annotations that are required by Clang. Enable lock
context analysis in the Makefile.

Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Let Clang verify lock and unlock calls. Enable lock context analysis in the
Makefile.

Acked-by: Jack Wang <jinpu.wang@ionos.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Now that all locking functions in block drivers have been annotated,
enable lock context analysis for all block drivers at the top level of
drivers/block/.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
@blktests-ci blktests-ci Bot force-pushed the series/1108850=>for-next branch from 4c79a4a to 8989b71 Compare July 7, 2026 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant