Commit 9bc5c397 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

block: fold bdev_unhash_inode into invalidate_partition

invalidate_partition and bdev_unhash_inode are always paired, and
invalidate_partition already does an icache lookup for the block device
inode.  Piggy back on that to remove the inode from the hash.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 02d33b67
...@@ -888,6 +888,12 @@ static void invalidate_partition(struct gendisk *disk, int partno) ...@@ -888,6 +888,12 @@ static void invalidate_partition(struct gendisk *disk, int partno)
fsync_bdev(bdev); fsync_bdev(bdev);
__invalidate_device(bdev, true); __invalidate_device(bdev, true);
/*
* Unhash the bdev inode for this device so that it gets evicted as soon
* as last inode reference is dropped.
*/
remove_inode_hash(bdev->bd_inode);
bdput(bdev); bdput(bdev);
} }
...@@ -909,13 +915,11 @@ void del_gendisk(struct gendisk *disk) ...@@ -909,13 +915,11 @@ void del_gendisk(struct gendisk *disk)
DISK_PITER_INCL_EMPTY | DISK_PITER_REVERSE); DISK_PITER_INCL_EMPTY | DISK_PITER_REVERSE);
while ((part = disk_part_iter_next(&piter))) { while ((part = disk_part_iter_next(&piter))) {
invalidate_partition(disk, part->partno); invalidate_partition(disk, part->partno);
bdev_unhash_inode(part_devt(part));
delete_partition(disk, part); delete_partition(disk, part);
} }
disk_part_iter_exit(&piter); disk_part_iter_exit(&piter);
invalidate_partition(disk, 0); invalidate_partition(disk, 0);
bdev_unhash_inode(disk_devt(disk));
set_capacity(disk, 0); set_capacity(disk, 0);
disk->flags &= ~GENHD_FL_UP; disk->flags &= ~GENHD_FL_UP;
up_write(&disk->lookup_sem); up_write(&disk->lookup_sem);
......
...@@ -883,21 +883,6 @@ static int bdev_set(struct inode *inode, void *data) ...@@ -883,21 +883,6 @@ static int bdev_set(struct inode *inode, void *data)
static LIST_HEAD(all_bdevs); static LIST_HEAD(all_bdevs);
/*
* If there is a bdev inode for this device, unhash it so that it gets evicted
* as soon as last inode reference is dropped.
*/
void bdev_unhash_inode(dev_t dev)
{
struct inode *inode;
inode = ilookup5(blockdev_superblock, hash(dev), bdev_test, &dev);
if (inode) {
remove_inode_hash(inode);
iput(inode);
}
}
struct block_device *bdget(dev_t dev) struct block_device *bdget(dev_t dev)
{ {
struct block_device *bdev; struct block_device *bdev;
......
...@@ -2581,7 +2581,6 @@ extern struct kmem_cache *names_cachep; ...@@ -2581,7 +2581,6 @@ extern struct kmem_cache *names_cachep;
#ifdef CONFIG_BLOCK #ifdef CONFIG_BLOCK
extern int register_blkdev(unsigned int, const char *); extern int register_blkdev(unsigned int, const char *);
extern void unregister_blkdev(unsigned int, const char *); extern void unregister_blkdev(unsigned int, const char *);
extern void bdev_unhash_inode(dev_t dev);
extern struct block_device *bdget(dev_t); extern struct block_device *bdget(dev_t);
extern struct block_device *bdgrab(struct block_device *bdev); extern struct block_device *bdgrab(struct block_device *bdev);
extern void bd_set_size(struct block_device *, loff_t size); extern void bd_set_size(struct block_device *, loff_t size);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment