Thread (40 messages) 40 messages, 6 authors, 2017-03-08

Re: [PATCH 04/13] block: Move bdi_unregister() to del_gendisk()

From: Bart Van Assche <hidden>
Date: 2017-02-21 19:53:29

On 02/21/2017 09:55 AM, Jan Kara wrote:=0A=
quoted hunk ↗ jump to hunk
diff --git a/block/blk-core.c b/block/blk-core.c=0A=
index 47104f6a398b..9a901dcfdd5c 100644=0A=
--- a/block/blk-core.c=0A=
+++ b/block/blk-core.c=0A=
@@ -580,8 +580,6 @@ void blk_cleanup_queue(struct request_queue *q)=0A=
 		q->queue_lock =3D &q->__queue_lock;=0A=
 	spin_unlock_irq(lock);=0A=
 =0A=
-	bdi_unregister(q->backing_dev_info);=0A=
-=0A=
 	/* @q is and will stay empty, shutdown and put */=0A=
 	blk_put_queue(q);=0A=
 }=0A=
diff --git a/block/genhd.c b/block/genhd.c=0A=
index f6c4d4400759..68c613edb93a 100644=0A=
--- a/block/genhd.c=0A=
+++ b/block/genhd.c=0A=
@@ -660,6 +660,13 @@ void del_gendisk(struct gendisk *disk)=0A=
 	disk->flags &=3D ~GENHD_FL_UP;=0A=
 =0A=
 	sysfs_remove_link(&disk_to_dev(disk)->kobj, "bdi");=0A=
+	/*=0A=
+	 * Unregister bdi before releasing device numbers (as they can get=0A=
+	 * reused and we'd get clashes in sysfs) but after bdev inodes are=0A=
+	 * unhashed and thus will be soon destroyed as bdev inode's reference=
=0A=
+	 * to wb_writeback can block bdi_unregister().=0A=
+	 */=0A=
+	bdi_unregister(disk->queue->backing_dev_info);=0A=
 	blk_unregister_queue(disk);=0A=
 	blk_unregister_region(disk_devt(disk), disk->minors);=0A=
=0A=
This change looks suspicious to me. There are drivers that create a=0A=
block layer queue but neither call device_add_disk() nor del_gendisk(),=0A=
e.g. drivers/scsi/st.c. Although bdi_init() will be called for the=0A=
queues created by these drivers, this patch will cause the=0A=
bdi_unregister() call to be skipped for these drivers.=0A=
=0A=
Bart.=0A=
=0A=
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help