Skip to content

Commit

Permalink
block: only bdi_unregister() in del_gendisk() if !GENHD_FL_HIDDEN
Browse files Browse the repository at this point in the history
device_add_disk() will only call bdi_register_owner() if
!GENHD_FL_HIDDEN, so it follows that del_gendisk() should only call
bdi_unregister() if !GENHD_FL_HIDDEN.

Found with code inspection.  bdi_unregister() won't do any harm if
bdi_register_owner() wasn't used but best to avoid the unnecessary
call to bdi_unregister().

Fixes: 8ddcd65 ("block: introduce GENHD_FL_HIDDEN")
Signed-off-by: Mike Snitzer <[email protected]>
Reviewed-by: Ming Lei <[email protected]>
Reviewed-by: Hannes Reinecke <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
snitm authored and axboe committed Jan 15, 2018
1 parent bf9ae8c commit bc8d062
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion block/genhd.c
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,8 @@ void del_gendisk(struct gendisk *disk)
* Unregister bdi before releasing device numbers (as they can
* get reused and we'd get clashes in sysfs).
*/
bdi_unregister(disk->queue->backing_dev_info);
if (!(disk->flags & GENHD_FL_HIDDEN))
bdi_unregister(disk->queue->backing_dev_info);
blk_unregister_queue(disk);
} else {
WARN_ON(1);
Expand Down

0 comments on commit bc8d062

Please sign in to comment.