structblock_device_operations { blk_qc_t (*submit_bio) (struct bio *bio); int (*open) (struct block_device *, fmode_t); void (*release) (struct gendisk *, fmode_t); int (*rw_page)(struct block_device *, sector_t, struct page *, unsignedint); int (*ioctl) (struct block_device *, fmode_t, unsigned, unsignedlong); int (*compat_ioctl) (struct block_device *, fmode_t, unsigned, unsignedlong); unsignedint(*check_events)(struct gendisk *disk, unsignedint clearing); /* ->media_changed() is DEPRECATED, use ->check_events() instead */ void (*unlock_native_capacity) (struct gendisk *); int (*getgeo)(struct block_device *, struct hd_geometry *); int (*set_read_only)(struct block_device *bdev, bool ro); /* this callback is with swap_lock and sometimes page table lock held */ void (*swap_slot_free_notify) (struct block_device *, unsignedlong); int (*report_zones)(struct gendisk *, sector_t sector, unsignedint nr_zones, report_zones_cb cb, void *data); char *(*devnode)(struct gendisk *disk, umode_t *mode); structmodule *owner; conststructpr_ops *pr_ops;
/* * Special callback for probing GPT entry at a given sector. * Needed by Android devices, used by GPT scanner and MMC blk * driver. */ int (*alternative_gpt_sector)(struct gendisk *disk, sector_t *sector); };
structgendisk { /* major, first_minor and minors are input parameters only, * don't use directly. Use disk_devt() and disk_max_parts(). */ int major; /* major number of driver */ int first_minor; int minors; /* maximum number of minors, =1 for * disks that can't be partitioned. */
char disk_name[DISK_NAME_LEN]; /* name of major driver */
unsignedshort events; /* supported events */ unsignedshort event_flags; /* flags related to event processing */
// 新版 /** * blk_alloc_disk - allocate a gendisk structure * @node_id: numa node to allocate on * * Allocate and pre-initialize a gendisk structure for use with BIO based * drivers. * * Context: can sleep */ #define blk_alloc_disk(node_id) \ ({ \ static struct lock_class_key __key; \ \ __blk_alloc_disk(node_id, &__key); \ })
void *bi_private; #ifdef CONFIG_BLK_CGROUP /* * Represents the association of the css and request_queue for the bio. * If a bio goes direct to device, it will not have a blkg as it will * not have a request_queue associated with it. The reference is put * on release of the bio. */ structblkcg_gq *bi_blkg; structbio_issuebi_issue; #ifdef CONFIG_BLK_CGROUP_IOCOST u64 bi_iocost_cost; #endif #endif
union { #if defined(CONFIG_BLK_DEV_INTEGRITY) structbio_integrity_payload *bi_integrity;/* data integrity */ #endif };
unsignedshort bi_vcnt; /* how many bio_vec's */
/* * Everything starting with bi_max_vecs will be preserved by bio_reset() */
unsignedshort bi_max_vecs; /* max bvl_vecs we can hold */
atomic_t __bi_cnt; /* pin count */
structbio_vec *bi_io_vec;/* the actual vec list */
structbio_set *bi_pool;
/* * We can inline a number of vecs at the end of the bio, to avoid * double allocations for a small number of bio_vecs. This member * MUST obviously be kept at the very end of the bio. */ structbio_vecbi_inline_vecs[]; };