summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2023-06-01 12:44:49 +0300
committerJens Axboe <axboe@kernel.dk>2023-06-05 19:53:04 +0300
commit69f90b70bdb62e1a930239d33579e04884cd0b9a (patch)
treefd3b9e0b4f24710fa26b034b65088c4d7e9653e8
parenta4f75764d16bed317276b05a9fe2c179ef61680d (diff)
downloadlinux-69f90b70bdb62e1a930239d33579e04884cd0b9a.tar.xz
block: unhash the inode earlier in delete_partition
Move the call to remove_inode_hash to the beginning of delete_partition, as we want to prevent opening a block_device that is about to be removed ASAP. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Jan Kara <jack@suse.cz> Acked-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Link: https://lore.kernel.org/r/20230601094459.1350643-7-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--block/partitions/core.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/block/partitions/core.c b/block/partitions/core.c
index 82d26427deae..9d1debaa5caf 100644
--- a/block/partitions/core.c
+++ b/block/partitions/core.c
@@ -267,6 +267,12 @@ static void delete_partition(struct block_device *part)
{
lockdep_assert_held(&part->bd_disk->open_mutex);
+ /*
+ * 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);
+
fsync_bdev(part);
__invalidate_device(part, true);
@@ -274,12 +280,6 @@ static void delete_partition(struct block_device *part)
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);
}