Skip to content

Commit f610333

Browse files
committed
block: assert that we're not holding open_mutex over blk_report_disk_dead
blk_report_disk_dead() has the following major callers: (1) del_gendisk() (2) blk_mark_disk_dead() Since del_gendisk() acquires disk->open_mutex it's clear that all callers are assumed to be called without disk->open_mutex held. In turn, blk_report_disk_dead() is called without disk->open_mutex held in del_gendisk(). All callers of blk_mark_disk_dead() call it without disk->open_mutex as well. Ensure that it is clear that blk_report_disk_dead() is called without disk->open_mutex on purpose by asserting it and a comment in the code. Signed-off-by: Christoph Hellwig <hch@lst.de> Link: https://lore.kernel.org/r/20231017184823.1383356-5-hch@lst.de Reviewed-by: Ming Lei <ming.lei@redhat.com> Reviewed-by: Jan Kara <jack@suse.cz> Reviewed-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 6e57236 commit f610333

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

block/genhd.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,13 @@ static void blk_report_disk_dead(struct gendisk *disk, bool surprise)
559559
struct block_device *bdev;
560560
unsigned long idx;
561561

562+
/*
563+
* On surprise disk removal, bdev_mark_dead() may call into file
564+
* systems below. Make it clear that we're expecting to not hold
565+
* disk->open_mutex.
566+
*/
567+
lockdep_assert_not_held(&disk->open_mutex);
568+
562569
rcu_read_lock();
563570
xa_for_each(&disk->part_tbl, idx, bdev) {
564571
if (!kobject_get_unless_zero(&bdev->bd_device.kobj))

0 commit comments

Comments
 (0)