Unhash the block device inodes as early as possible. This ensures that
the inode and thus block_device an't be found in the inode hash as soon
as we start deleting the disk, instead of finding it and rejecting it
later because GENHD_FL_UP is cleared.
Signed-off-by: Christoph Hellwig <hch@lst.de>
if (WARN_ON_ONCE(!disk->queue))
return;
+ remove_inode_hash(disk->part0->bd_inode);
+
blk_integrity_del(disk);
disk_del_events(disk);
fsync_bdev(disk->part0);
__invalidate_device(disk->part0, true);
- /*
- * Unhash the bdev inode for this device so that it can't be looked
- * up any more even if openers still hold references to it.
- */
- remove_inode_hash(disk->part0->bd_inode);
-
set_capacity(disk, 0);
if (!(disk->flags & GENHD_FL_HIDDEN)) {
{
lockdep_assert_held(&part->bd_disk->open_mutex);
+ remove_inode_hash(part->bd_inode);
+
fsync_bdev(part);
__invalidate_device(part, true);
kobject_put(part->bd_holder_dir);
device_del(&part->bd_device);
- /*
- * Remove the block device from the inode hash, so that it cannot be
- * looked up any more even when openers still hold references.
- */
- remove_inode_hash(part->bd_inode);
-
put_device(&part->bd_device);
}