summaryrefslogtreecommitdiff
path: root/block/genhd.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2021-07-22 10:53:56 +0300
committerJens Axboe <axboe@kernel.dk>2021-08-02 22:37:28 +0300
commitd7a66574b34e0b354442140927f9b787efccabfd (patch)
tree36de0c3d2edd2acd41e718d36283d645b6e97166 /block/genhd.c
parenta45e43cad798173b41e0d6f119784826d3ead02c (diff)
downloadlinux-d7a66574b34e0b354442140927f9b787efccabfd.tar.xz
block: unhash the whole device inode earlier
Unhash the whole device inode early in del_gendisk. This allows to remove the first GENHD_FL_UP check in the open path as we simply won't find a just removed inode. The second non-racy check after taking open_mutex is still kept. Signed-off-by: Christoph Hellwig <hch@lst.de> Link: https://lore.kernel.org/r/20210722075402.983367-4-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/genhd.c')
-rw-r--r--block/genhd.c7
1 files changed, 1 insertions, 6 deletions
diff --git a/block/genhd.c b/block/genhd.c
index 298ee78c1bda..716f5ca479ad 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -585,6 +585,7 @@ void del_gendisk(struct gendisk *disk)
disk_del_events(disk);
mutex_lock(&disk->open_mutex);
+ remove_inode_hash(disk->part0->bd_inode);
disk->flags &= ~GENHD_FL_UP;
blk_drop_partitions(disk);
mutex_unlock(&disk->open_mutex);
@@ -592,12 +593,6 @@ void del_gendisk(struct gendisk *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)) {