disk_register_independent_access_ranges() and disk_unregister_independent_access_ranges() must be called with q->sysfs_lock held. This is already verified at runtime with lockdep_assert_held(). Additionally annotate both the declarations in block/blk.h and the definitions with __must_hold(&disk->queue->sysfs_lock) such that Clang verifies at compile time that all callers hold that lock. Signed-off-by: Bart Van Assche --- block/blk-ia-ranges.c | 2 ++ block/blk.h | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/block/blk-ia-ranges.c b/block/blk-ia-ranges.c index 7be8b58893c9..9a0d83e099f4 100644 --- a/block/blk-ia-ranges.c +++ b/block/blk-ia-ranges.c @@ -106,6 +106,7 @@ static const struct kobj_type blk_ia_ranges_ktype = { * Register with sysfs a set of independent access ranges for @disk. */ int disk_register_independent_access_ranges(struct gendisk *disk) + __must_hold(&disk->queue->sysfs_lock) { struct blk_independent_access_ranges *iars = disk->ia_ranges; struct request_queue *q = disk->queue; @@ -149,6 +150,7 @@ int disk_register_independent_access_ranges(struct gendisk *disk) } void disk_unregister_independent_access_ranges(struct gendisk *disk) + __must_hold(&disk->queue->sysfs_lock) { struct request_queue *q = disk->queue; struct blk_independent_access_ranges *iars = disk->ia_ranges; diff --git a/block/blk.h b/block/blk.h index b60556e482b2..264baeabc964 100644 --- a/block/blk.h +++ b/block/blk.h @@ -711,8 +711,10 @@ long compat_blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg); extern const struct address_space_operations def_blk_aops; -int disk_register_independent_access_ranges(struct gendisk *disk); -void disk_unregister_independent_access_ranges(struct gendisk *disk); +int disk_register_independent_access_ranges(struct gendisk *disk) + __must_hold(&disk->queue->sysfs_lock); +void disk_unregister_independent_access_ranges(struct gendisk *disk) + __must_hold(&disk->queue->sysfs_lock); int should_fail_bio(struct bio *bio); #ifdef CONFIG_FAIL_MAKE_REQUEST