Message ID | 20230518042323.663189-7-hch@lst.de (mailing list archive) |
---|---|
State | Superseded, archived |
Headers | show |
Series | [01/13] block: factor out a bd_end_claim helper from blkdev_put | expand |
On Thu 18-05-23 06:23:15, Christoph Hellwig wrote: > 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> The justification looks a bit bogus because we hold disk->open_mutex in delete_partition() which serializes with any opens anyway. But it's a harmless code move so if it helps later then sure... Feel free to add: Reviewed-by: Jan Kara <jack@suse.cz> Honza > --- > block/partitions/core.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/block/partitions/core.c b/block/partitions/core.c > index 49e0496ff23c1e..fa5c707fe0ad2f 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); > } > > -- > 2.39.2 >
diff --git a/block/partitions/core.c b/block/partitions/core.c index 49e0496ff23c1e..fa5c707fe0ad2f 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); }
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> --- block/partitions/core.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)