summaryrefslogtreecommitdiff
path: root/include/linux/genhd.h
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2020-11-26 09:23:26 +0100
committerJens Axboe <axboe@kernel.dk>2020-12-01 14:53:39 -0700
commit22ae8ce8b89241c94ac00c237752c0ffa37ba5ae (patch)
treeaf6d4dfd72e76789c25c64cd1765f037d91f6b72 /include/linux/genhd.h
parent4e7b5671c6a883d94b5428e1a9c141bbd56cb2a6 (diff)
downloadlinux-next-22ae8ce8b89241c94ac00c237752c0ffa37ba5ae.tar.gz
block: simplify bdev/disk lookup in blkdev_get
To simplify block device lookup and a few other upcoming areas, make sure that we always have a struct block_device available for each disk and each partition, and only find existing block devices in bdget. The only downside of this is that each device and partition uses a little more memory. The upside will be that a lot of code can be simplified. With that all we need to look up the block device is to lookup the inode and do a few sanity checks on the gendisk, instead of the separate lookup for the gendisk. For blk-cgroup which wants to access a gendisk without opening it, a new blkdev_{get,put}_no_open low-level interface is added to replace the previous get_gendisk use. Note that the change to look up block device directly instead of the two step lookup using struct gendisk causes a subtile change in behavior: accessing a non-existing partition on an existing block device can now cause a call to request_module. That call is harmless, and in practice no recent system will access these nodes as they aren't created by udev and static /dev/ setups are unusual. 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.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index ca5e356084c3..42a51653c730 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -65,6 +65,7 @@ struct hd_struct {
struct disk_stats __percpu *dkstats;
struct percpu_ref ref;
+ struct block_device *bdev;
struct device __dev;
struct kobject *holder_dir;
int policy, partno;
@@ -193,7 +194,6 @@ struct gendisk {
int flags;
unsigned long state;
#define GD_NEED_PART_SCAN 0
- struct rw_semaphore lookup_sem;
struct kobject *slave_dir;
struct timer_rand_state *random;
@@ -300,7 +300,6 @@ static inline void add_disk_no_queue_reg(struct gendisk *disk)
}
extern void del_gendisk(struct gendisk *gp);
-extern struct gendisk *get_gendisk(dev_t dev, int *partno);
extern struct block_device *bdget_disk(struct gendisk *disk, int partno);
extern void set_disk_ro(struct gendisk *disk, int flag);
@@ -338,7 +337,6 @@ int blk_drop_partitions(struct block_device *bdev);
extern struct gendisk *__alloc_disk_node(int minors, int node_id);
extern void put_disk(struct gendisk *disk);
-extern void put_disk_and_module(struct gendisk *disk);
#define alloc_disk_node(minors, node_id) \
({ \
@@ -388,7 +386,10 @@ static inline void bd_unlink_disk_holder(struct block_device *bdev,
}
#endif /* CONFIG_SYSFS */
+extern struct rw_semaphore bdev_lookup_sem;
+
dev_t blk_lookup_devt(const char *name, int partno);
+void blk_request_module(dev_t devt);
#ifdef CONFIG_BLOCK
void printk_all_partitions(void);
#else /* CONFIG_BLOCK */