#include <linux/module.h>
#include <linux/ctype.h>
#include <linux/fs.h>
#include <linux/kdev_t.h>
#include <linux/kernel.h>
#include <linux/blkdev.h>
#include <linux/backing-dev.h>
#include <linux/init.h>
#include <linux/spinlock.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/slab.h>
#include <linux/kmod.h>
#include <linux/major.h>
#include <linux/mutex.h>
#include <linux/idr.h>
#include <linux/log2.h>
#include <linux/pm_runtime.h>
#include <linux/badblocks.h>
#include <linux/part_stat.h>
#include <linux/blktrace_api.h>
#include "blk-throttle.h"
#include "blk.h"
#include "blk-mq-sched.h"
#include "blk-rq-qos.h"
#include "blk-cgroup.h"
static struct kobject *block_depr;
static atomic64_t diskseq;
#define NR_EXT_DEVT …
static DEFINE_IDA(ext_devt_ida);
void set_capacity(struct gendisk *disk, sector_t sectors)
{ … }
EXPORT_SYMBOL(…);
bool set_capacity_and_notify(struct gendisk *disk, sector_t size)
{ … }
EXPORT_SYMBOL_GPL(…);
static void part_stat_read_all(struct block_device *part,
struct disk_stats *stat)
{ … }
unsigned int part_in_flight(struct block_device *part)
{ … }
static void part_in_flight_rw(struct block_device *part,
unsigned int inflight[2])
{ … }
#define BLKDEV_MAJOR_HASH_SIZE …
static struct blk_major_name { … } *major_names[BLKDEV_MAJOR_HASH_SIZE];
static DEFINE_MUTEX(major_names_lock);
static DEFINE_SPINLOCK(major_names_spinlock);
static inline int major_to_index(unsigned major)
{ … }
#ifdef CONFIG_PROC_FS
void blkdev_show(struct seq_file *seqf, off_t offset)
{ … }
#endif
int __register_blkdev(unsigned int major, const char *name,
void (*probe)(dev_t devt))
{ … }
EXPORT_SYMBOL(…);
void unregister_blkdev(unsigned int major, const char *name)
{ … }
EXPORT_SYMBOL(…);
int blk_alloc_ext_minor(void)
{ … }
void blk_free_ext_minor(unsigned int minor)
{ … }
void disk_uevent(struct gendisk *disk, enum kobject_action action)
{ … }
EXPORT_SYMBOL_GPL(…);
int disk_scan_partitions(struct gendisk *disk, blk_mode_t mode)
{ … }
int __must_check device_add_disk(struct device *parent, struct gendisk *disk,
const struct attribute_group **groups)
{ … }
EXPORT_SYMBOL(…);
static void blk_report_disk_dead(struct gendisk *disk, bool surprise)
{ … }
static void __blk_mark_disk_dead(struct gendisk *disk)
{ … }
void blk_mark_disk_dead(struct gendisk *disk)
{ … }
EXPORT_SYMBOL_GPL(…);
void del_gendisk(struct gendisk *disk)
{ … }
EXPORT_SYMBOL(…);
void invalidate_disk(struct gendisk *disk)
{ … }
EXPORT_SYMBOL(…);
static ssize_t disk_badblocks_show(struct device *dev,
struct device_attribute *attr,
char *page)
{ … }
static ssize_t disk_badblocks_store(struct device *dev,
struct device_attribute *attr,
const char *page, size_t len)
{ … }
#ifdef CONFIG_BLOCK_LEGACY_AUTOLOAD
void blk_request_module(dev_t devt)
{ … }
#endif
#ifdef CONFIG_PROC_FS
static void *disk_seqf_start(struct seq_file *seqf, loff_t *pos)
{ … }
static void *disk_seqf_next(struct seq_file *seqf, void *v, loff_t *pos)
{ … }
static void disk_seqf_stop(struct seq_file *seqf, void *v)
{ … }
static void *show_partition_start(struct seq_file *seqf, loff_t *pos)
{ … }
static int show_partition(struct seq_file *seqf, void *v)
{ … }
static const struct seq_operations partitions_op = …;
#endif
static int __init genhd_device_init(void)
{ … }
subsys_initcall(genhd_device_init);
static ssize_t disk_range_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t disk_ext_range_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t disk_removable_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t disk_hidden_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t disk_ro_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
ssize_t part_size_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
ssize_t part_stat_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
ssize_t part_inflight_show(struct device *dev, struct device_attribute *attr,
char *buf)
{ … }
static ssize_t disk_capability_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t disk_alignment_offset_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{ … }
static ssize_t disk_discard_alignment_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{ … }
static ssize_t diskseq_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t partscan_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static DEVICE_ATTR(range, 0444, disk_range_show, NULL);
static DEVICE_ATTR(ext_range, 0444, disk_ext_range_show, NULL);
static DEVICE_ATTR(removable, 0444, disk_removable_show, NULL);
static DEVICE_ATTR(hidden, 0444, disk_hidden_show, NULL);
static DEVICE_ATTR(ro, 0444, disk_ro_show, NULL);
static DEVICE_ATTR(size, 0444, part_size_show, NULL);
static DEVICE_ATTR(alignment_offset, 0444, disk_alignment_offset_show, NULL);
static DEVICE_ATTR(discard_alignment, 0444, disk_discard_alignment_show, NULL);
static DEVICE_ATTR(capability, 0444, disk_capability_show, NULL);
static DEVICE_ATTR(stat, 0444, part_stat_show, NULL);
static DEVICE_ATTR(inflight, 0444, part_inflight_show, NULL);
static DEVICE_ATTR(badblocks, 0644, disk_badblocks_show, disk_badblocks_store);
static DEVICE_ATTR(diskseq, 0444, diskseq_show, NULL);
static DEVICE_ATTR(partscan, 0444, partscan_show, NULL);
#ifdef CONFIG_FAIL_MAKE_REQUEST
ssize_t part_fail_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
ssize_t part_fail_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static struct device_attribute dev_attr_fail = …;
#endif
#ifdef CONFIG_FAIL_IO_TIMEOUT
static struct device_attribute dev_attr_fail_timeout = …;
#endif
static struct attribute *disk_attrs[] = …;
static umode_t disk_visible(struct kobject *kobj, struct attribute *a, int n)
{ … }
static struct attribute_group disk_attr_group = …;
static const struct attribute_group *disk_attr_groups[] = …;
static void disk_release(struct device *dev)
{ … }
static int block_uevent(const struct device *dev, struct kobj_uevent_env *env)
{ … }
const struct class block_class = …;
static char *block_devnode(const struct device *dev, umode_t *mode,
kuid_t *uid, kgid_t *gid)
{ … }
const struct device_type disk_type = …;
#ifdef CONFIG_PROC_FS
static int diskstats_show(struct seq_file *seqf, void *v)
{ … }
static const struct seq_operations diskstats_op = …;
static int __init proc_genhd_init(void)
{ … }
module_init(…) …;
#endif
dev_t part_devt(struct gendisk *disk, u8 partno)
{ … }
struct gendisk *__alloc_disk_node(struct request_queue *q, int node_id,
struct lock_class_key *lkclass)
{ … }
struct gendisk *__blk_alloc_disk(struct queue_limits *lim, int node,
struct lock_class_key *lkclass)
{ … }
EXPORT_SYMBOL(…);
void put_disk(struct gendisk *disk)
{ … }
EXPORT_SYMBOL(…);
static void set_disk_ro_uevent(struct gendisk *gd, int ro)
{ … }
void set_disk_ro(struct gendisk *disk, bool read_only)
{ … }
EXPORT_SYMBOL(…);
void inc_diskseq(struct gendisk *disk)
{ … }