Skip to content

Commit

Permalink
block: unhash the inode earlier in delete_partition
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Christoph Hellwig authored and Jens Axboe committed Jun 5, 2023
1 parent a4f7576 commit 69f90b7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions block/partitions/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,19 +267,19 @@ 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);

xa_erase(&part->bd_disk->part_tbl, part->bd_partno);
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);
}

Expand Down

0 comments on commit 69f90b7

Please sign in to comment.