Skip to content

Commit

Permalink
block: warn when putting the final reference on a registered disk
Browse files Browse the repository at this point in the history
Warn when the last reference on a live disk is put without calling
del_gendisk first.  There are some BDI related bug reports that look
like a case of this, so make sure we have the proper instrumentation
to catch it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20211014130231.1468538-1-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Christoph Hellwig authored and Jens Axboe committed Oct 17, 2021
1 parent f7bf358 commit a204176
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions block/genhd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1078,6 +1078,7 @@ static void disk_release(struct device *dev)
struct gendisk *disk = dev_to_disk(dev);

might_sleep();
WARN_ON_ONCE(disk_live(disk));

disk_release_events(disk);
kfree(disk->random);
Expand Down

0 comments on commit a204176

Please sign in to comment.