bd_may_claim() and bd_clear_claiming() must be called with bdev_lock held. This is already verified at runtime with lockdep_assert_held(). Additionally annotate both functions with __must_hold(&bdev_lock) such that Clang verifies at compile time that all callers hold bdev_lock. Signed-off-by: Bart Van Assche --- block/bdev.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/block/bdev.c b/block/bdev.c index 87dbcffb21da..54446d97940b 100644 --- a/block/bdev.c +++ b/block/bdev.c @@ -585,6 +585,7 @@ long nr_blockdev_pages(void) */ static bool bd_may_claim(struct block_device *bdev, void *holder, const struct blk_holder_ops *hops) + __must_hold(&bdev_lock) { struct block_device *whole = bdev_whole(bdev); @@ -660,6 +661,7 @@ int bd_prepare_to_claim(struct block_device *bdev, void *holder, EXPORT_SYMBOL_GPL(bd_prepare_to_claim); /* only for the loop driver */ static void bd_clear_claiming(struct block_device *whole, void *holder) + __must_hold(&bdev_lock) { lockdep_assert_held(&bdev_lock); /* tell others that we're done */