Message ID | 20180110024104.34885-2-snitzer@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Tue, Jan 09 2018 at 9:41pm -0500, Mike Snitzer <snitzer@redhat.com> wrote: > device_add_disk() will only call bdi_register_owner() if > !GENHD_FL_HIDDEN so it follows that bdi_unregister() should be avoided > for !GENHD_FL_HIDDEN in del_gendisk(). This ^ should be "GENHD_FL_HIDDEN". Sorry for the cut-n-paste typo.
It's in fact completely harmless :) But not even calling it obviously is just as fine.
diff --git a/block/genhd.c b/block/genhd.c index 96a66f671720..00620e01e043 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -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);
device_add_disk() will only call bdi_register_owner() if !GENHD_FL_HIDDEN so it follows that bdi_unregister() should be avoided for !GENHD_FL_HIDDEN in del_gendisk(). Found with code inspection. bdi_unregister() won't do much harm if bdi_register_owner() wasn't used but best to avoid it. Fixes: 8ddcd65325 ("block: introduce GENHD_FL_HIDDEN") Signed-off-by: Mike Snitzer <snitzer@redhat.com> --- block/genhd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)