block: pre-initialize struct block_device in bdev_alloc_inode
bdev_evict_inode and bdev_free_inode are also called for the root inode
of bdevfs, for which bdev_alloc is never called. Move the zeroing o
f struct block_device and the initialization of the bd_bdi field into
bdev_alloc_inode to make sure they are initialized for the root inode
as well.
Fixes: e6cb53827e
("block: initialize struct block_device in bdev_alloc")
Reported-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Tested-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
04b1ecb6a4
commit
2d2f6f1b47
@ -776,8 +776,11 @@ static struct kmem_cache * bdev_cachep __read_mostly;
|
|||||||
static struct inode *bdev_alloc_inode(struct super_block *sb)
|
static struct inode *bdev_alloc_inode(struct super_block *sb)
|
||||||
{
|
{
|
||||||
struct bdev_inode *ei = kmem_cache_alloc(bdev_cachep, GFP_KERNEL);
|
struct bdev_inode *ei = kmem_cache_alloc(bdev_cachep, GFP_KERNEL);
|
||||||
|
|
||||||
if (!ei)
|
if (!ei)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
memset(&ei->bdev, 0, sizeof(ei->bdev));
|
||||||
|
ei->bdev.bd_bdi = &noop_backing_dev_info;
|
||||||
return &ei->vfs_inode;
|
return &ei->vfs_inode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -871,14 +874,12 @@ struct block_device *bdev_alloc(struct gendisk *disk, u8 partno)
|
|||||||
mapping_set_gfp_mask(&inode->i_data, GFP_USER);
|
mapping_set_gfp_mask(&inode->i_data, GFP_USER);
|
||||||
|
|
||||||
bdev = I_BDEV(inode);
|
bdev = I_BDEV(inode);
|
||||||
memset(bdev, 0, sizeof(*bdev));
|
|
||||||
mutex_init(&bdev->bd_mutex);
|
mutex_init(&bdev->bd_mutex);
|
||||||
mutex_init(&bdev->bd_fsfreeze_mutex);
|
mutex_init(&bdev->bd_fsfreeze_mutex);
|
||||||
spin_lock_init(&bdev->bd_size_lock);
|
spin_lock_init(&bdev->bd_size_lock);
|
||||||
bdev->bd_disk = disk;
|
bdev->bd_disk = disk;
|
||||||
bdev->bd_partno = partno;
|
bdev->bd_partno = partno;
|
||||||
bdev->bd_inode = inode;
|
bdev->bd_inode = inode;
|
||||||
bdev->bd_bdi = &noop_backing_dev_info;
|
|
||||||
#ifdef CONFIG_SYSFS
|
#ifdef CONFIG_SYSFS
|
||||||
INIT_LIST_HEAD(&bdev->bd_holder_disks);
|
INIT_LIST_HEAD(&bdev->bd_holder_disks);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user