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); }