summaryrefslogtreecommitdiff
path: root/include/linux/genhd.h
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2020-11-26 18:47:17 +0100
committerJens Axboe <axboe@kernel.dk>2020-12-01 14:53:40 -0700
commitcb8432d650fe3be58bb962bc8e602dc405510327 (patch)
tree5e893d44ba2449080db89f00098f11259384a56a /include/linux/genhd.h
parent83950d359010a493462d58c712b1124c877d1b3b (diff)
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/linux/genhd.h')
-rw-r--r--include/linux/genhd.h14
1 files changed, 6 insertions, 8 deletions
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);