block: allocate struct hd_struct as part of struct bdev_inode
Allocate hd_struct together with struct block_device to pre-load the lifetime rule changes in preparation of merging the two structures. Note that part0 was previously embedded into struct gendisk, but is a separate allocation now, and already points to the block_device instead of the hd_struct. The lifetime of struct gendisk is still controlled by the struct device embedded in the part0 hd_struct. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Jan Kara <jack@suse.cz> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
83950d3590
commit
cb8432d650
15 changed files with 61 additions and 169 deletions
|
|
@ -59,7 +59,7 @@ struct block_device {
|
|||
} __randomize_layout;
|
||||
|
||||
#define bdev_whole(_bdev) \
|
||||
((_bdev)->bd_disk->part0.bdev)
|
||||
((_bdev)->bd_disk->part0)
|
||||
|
||||
#define bdev_kobj(_bdev) \
|
||||
(&part_to_dev((_bdev)->bd_part)->kobj)
|
||||
|
|
|
|||
|
|
@ -19,11 +19,12 @@
|
|||
#include <linux/blk_types.h>
|
||||
#include <asm/local.h>
|
||||
|
||||
#define dev_to_disk(device) container_of((device), struct gendisk, part0.__dev)
|
||||
#define dev_to_part(device) container_of((device), struct hd_struct, __dev)
|
||||
#define disk_to_dev(disk) (&(disk)->part0.__dev)
|
||||
#define part_to_dev(part) (&((part)->__dev))
|
||||
|
||||
#define dev_to_disk(device) (dev_to_part(device)->bdev->bd_disk)
|
||||
#define disk_to_dev(disk) (part_to_dev((disk)->part0->bd_part))
|
||||
|
||||
extern const struct device_type disk_type;
|
||||
extern struct device_type part_type;
|
||||
extern struct class block_class;
|
||||
|
|
@ -51,12 +52,9 @@ struct partition_meta_info {
|
|||
};
|
||||
|
||||
struct hd_struct {
|
||||
struct percpu_ref ref;
|
||||
|
||||
struct block_device *bdev;
|
||||
struct device __dev;
|
||||
int partno;
|
||||
struct rcu_work rcu_work;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -168,7 +166,7 @@ struct gendisk {
|
|||
* helpers.
|
||||
*/
|
||||
struct disk_part_tbl __rcu *part_tbl;
|
||||
struct hd_struct part0;
|
||||
struct block_device *part0;
|
||||
|
||||
const struct block_device_operations *fops;
|
||||
struct request_queue *queue;
|
||||
|
|
@ -278,7 +276,7 @@ extern void set_disk_ro(struct gendisk *disk, int flag);
|
|||
|
||||
static inline int get_disk_ro(struct gendisk *disk)
|
||||
{
|
||||
return disk->part0.bdev->bd_read_only;
|
||||
return disk->part0->bd_read_only;
|
||||
}
|
||||
|
||||
extern void disk_block_events(struct gendisk *disk);
|
||||
|
|
@ -302,7 +300,7 @@ static inline sector_t bdev_nr_sectors(struct block_device *bdev)
|
|||
|
||||
static inline sector_t get_capacity(struct gendisk *disk)
|
||||
{
|
||||
return bdev_nr_sectors(disk->part0.bdev);
|
||||
return bdev_nr_sectors(disk->part0);
|
||||
}
|
||||
|
||||
int bdev_disk_changed(struct block_device *bdev, bool invalidate);
|
||||
|
|
|
|||
|
|
@ -59,8 +59,8 @@ static inline void part_stat_set_all(struct hd_struct *part, int value)
|
|||
#define part_stat_add(part, field, addnd) do { \
|
||||
__part_stat_add((part), field, addnd); \
|
||||
if ((part)->partno) \
|
||||
__part_stat_add(&part_to_disk((part))->part0, \
|
||||
field, addnd); \
|
||||
__part_stat_add(part_to_disk((part))->part0->bd_part, \
|
||||
field, addnd); \
|
||||
} while (0)
|
||||
|
||||
#define part_stat_dec(part, field) \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue