提交 ab4b5705 编写于 作者: C Christoph Hellwig 提交者: Jens Axboe

block: move bd_part_count to struct gendisk

The bd_part_count value only makes sense for whole devices, so move it
to struct gendisk and give it a more descriptive name.
Signed-off-by: NChristoph Hellwig <hch@lst.de>
Reviewed-by: NHannes Reinecke <hare@suse.de>
Reviewed-by: NMing Lei <ming.lei@redhat.com>
Link: https://lore.kernel.org/r/20210525061301.2242282-7-hch@lst.deSigned-off-by: NJens Axboe <axboe@kernel.dk>
上级 c8276b95
...@@ -89,7 +89,7 @@ static int blkdev_reread_part(struct block_device *bdev, fmode_t mode) ...@@ -89,7 +89,7 @@ static int blkdev_reread_part(struct block_device *bdev, fmode_t mode)
return -EINVAL; return -EINVAL;
if (!capable(CAP_SYS_ADMIN)) if (!capable(CAP_SYS_ADMIN))
return -EACCES; return -EACCES;
if (bdev->bd_part_count) if (bdev->bd_disk->open_partitions)
return -EBUSY; return -EBUSY;
/* /*
......
...@@ -1253,7 +1253,7 @@ int bdev_disk_changed(struct block_device *bdev, bool invalidate) ...@@ -1253,7 +1253,7 @@ int bdev_disk_changed(struct block_device *bdev, bool invalidate)
return -ENXIO; return -ENXIO;
rescan: rescan:
if (bdev->bd_part_count) if (disk->open_partitions)
return -EBUSY; return -EBUSY;
sync_blockdev(bdev); sync_blockdev(bdev);
invalidate_bdev(bdev); invalidate_bdev(bdev);
...@@ -1348,7 +1348,7 @@ static int blkdev_get_part(struct block_device *part, fmode_t mode) ...@@ -1348,7 +1348,7 @@ static int blkdev_get_part(struct block_device *part, fmode_t mode)
if (!bdev_nr_sectors(part)) if (!bdev_nr_sectors(part))
goto out_blkdev_put; goto out_blkdev_put;
whole->bd_part_count++; disk->open_partitions++;
set_init_blocksize(part); set_init_blocksize(part);
if (part->bd_bdi == &noop_backing_dev_info) if (part->bd_bdi == &noop_backing_dev_info)
part->bd_bdi = bdi_get(disk->queue->backing_dev_info); part->bd_bdi = bdi_get(disk->queue->backing_dev_info);
...@@ -1370,7 +1370,7 @@ static void blkdev_put_part(struct block_device *part, fmode_t mode) ...@@ -1370,7 +1370,7 @@ static void blkdev_put_part(struct block_device *part, fmode_t mode)
if (--part->bd_openers) if (--part->bd_openers)
return; return;
blkdev_flush_mapping(part); blkdev_flush_mapping(part);
whole->bd_part_count--; whole->bd_disk->open_partitions--;
blkdev_put_whole(whole, mode); blkdev_put_whole(whole, mode);
bdput(whole); bdput(whole);
} }
......
...@@ -39,9 +39,6 @@ struct block_device { ...@@ -39,9 +39,6 @@ struct block_device {
#endif #endif
struct kobject *bd_holder_dir; struct kobject *bd_holder_dir;
u8 bd_partno; u8 bd_partno;
/* number of times partitions within this device have been opened. */
unsigned bd_part_count;
spinlock_t bd_size_lock; /* for bd_inode->i_size updates */ spinlock_t bd_size_lock; /* for bd_inode->i_size updates */
struct gendisk * bd_disk; struct gendisk * bd_disk;
struct backing_dev_info *bd_bdi; struct backing_dev_info *bd_bdi;
......
...@@ -156,6 +156,7 @@ struct gendisk { ...@@ -156,6 +156,7 @@ struct gendisk {
#define GD_QUEUE_REF 2 #define GD_QUEUE_REF 2
struct mutex open_mutex; /* open/close mutex */ struct mutex open_mutex; /* open/close mutex */
unsigned open_partitions; /* number of open partitions */
struct kobject *slave_dir; struct kobject *slave_dir;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册