summaryrefslogtreecommitdiff
path: root/include/linux/genhd.h
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2020-11-27 16:43:51 +0100
committerJens Axboe <axboe@kernel.dk>2020-12-01 14:53:40 -0700
commit0d02129e76edf91cf04fabf1efbc3a9a1f1d729a (patch)
tree20fd7e1e54d4430038eb74d8e276decee65ee7c3 /include/linux/genhd.h
parent9499ffc7521742e3fea32f6ac6c1213b6fc4e914 (diff)
block: merge struct block_device and struct hd_struct
Instead of having two structures that represent each block device with different life time rules, merge them into a single one. This also greatly simplifies the reference counting rules, as we can use the inode reference count as the main reference count for the new struct block_device, with the device model reference front ending it for device model interaction. 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.h40
1 files changed, 9 insertions, 31 deletions
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index cd23c80265b2..809aaa32d53c 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -19,12 +19,6 @@
#include <linux/blk_types.h>
#include <asm/local.h>
-#define dev_to_part(device) container_of((device), struct hd_struct, __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,11 +45,6 @@ struct partition_meta_info {
u8 volname[PARTITION_META_INFO_VOLNAMELTH];
};
-struct hd_struct {
- struct block_device *bdev;
- struct device __dev;
-};
-
/**
* DOC: genhd capability flags
*
@@ -190,19 +179,21 @@ struct gendisk {
struct lockdep_map lockdep_map;
};
+/*
+ * The gendisk is refcounted by the part0 block_device, and the bd_device
+ * therein is also used for device model presentation in sysfs.
+ */
+#define dev_to_disk(device) \
+ (dev_to_bdev(device)->bd_disk)
+#define disk_to_dev(disk) \
+ (&((disk)->part0->bd_device))
+
#if IS_REACHABLE(CONFIG_CDROM)
#define disk_to_cdi(disk) ((disk)->cdi)
#else
#define disk_to_cdi(disk) NULL
#endif
-static inline struct gendisk *part_to_disk(struct hd_struct *part)
-{
- if (unlikely(!part))
- return NULL;
- return part->bdev->bd_disk;
-}
-
static inline int disk_max_parts(struct gendisk *disk)
{
if (disk->flags & GENHD_FL_EXT_DEVT)
@@ -221,19 +212,6 @@ static inline dev_t disk_devt(struct gendisk *disk)
return MKDEV(disk->major, disk->first_minor);
}
-static inline dev_t part_devt(struct hd_struct *part)
-{
- return part_to_dev(part)->devt;
-}
-
-extern struct hd_struct *disk_get_part(struct gendisk *disk, int partno);
-
-static inline void disk_put_part(struct hd_struct *part)
-{
- if (likely(part))
- put_device(part_to_dev(part));
-}
-
/*
* Smarter partition iterator without context limits.
*/