summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2020-11-26 20:47:17 +0300
committerJens Axboe <axboe@kernel.dk>2020-12-02 00:53:40 +0300
commitcb8432d650fe3be58bb962bc8e602dc405510327 (patch)
tree5e893d44ba2449080db89f00098f11259384a56a /include
parent83950d359010a493462d58c712b1124c877d1b3b (diff)
downloadlinux-cb8432d650fe3be58bb962bc8e602dc405510327.tar.xz
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>
Diffstat (limited to 'include')
-rw-r--r--include/linux/blk_types.h2
-rw-r--r--include/linux/genhd.h14
-rw-r--r--include/linux/part_stat.h4
3 files changed, 9 insertions, 11 deletions
diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
index 758cf71c9aa2..6edea5c16259 100644
--- a/include/linux/blk_types.h
+++ b/include/linux/blk_types.h
@@ -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)
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index dcbf9ef7610e..df7319da013c 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -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);
diff --git a/include/linux/part_stat.h b/include/linux/part_stat.h
index 87ad60106e1d..680de036691e 100644
--- a/include/linux/part_stat.h
+++ b/include/linux/part_stat.h
@@ -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) \