1623 lines · 45.7 KB · C
RawDownload
#ifndef _LINUX_BLKDEV_H#define _LINUX_BLKDEV_H #include <linux/sched.h> #ifdef CONFIG_BLOCK #include <linux/major.h>#include <linux/genhd.h>#include <linux/list.h>#include <linux/llist.h>#include <linux/timer.h>#include <linux/workqueue.h>#include <linux/pagemap.h>#include <linux/backing-dev.h>#include <linux/wait.h>#include <linux/mempool.h>#include <linux/bio.h>#include <linux/stringify.h>#include <linux/gfp.h>#include <linux/bsg.h>#include <linux/smp.h>#include <linux/rcupdate.h> #include <asm/scatterlist.h> struct module;struct scsi_ioctl_command; struct request_queue;struct elevator_queue;struct request_pm_state;struct blk_trace;struct request;struct sg_io_hdr;struct bsg_job;struct blkcg_gq; #define BLKDEV_MIN_RQ	4#define BLKDEV_MAX_RQ	128	/* Default maximum */ /* * Maximum number of blkcg policies allowed to be registered concurrently. * Defined here to simplify include dependency. */#define BLKCG_MAX_POLS		2 struct request;typedef void (rq_end_io_fn)(struct request *, int); #define BLK_RL_SYNCFULL		(1U << 0)#define BLK_RL_ASYNCFULL	(1U << 1) struct request_list {	struct request_queue	*q;	/* the queue this rl belongs to */#ifdef CONFIG_BLK_CGROUP	struct blkcg_gq		*blkg;	/* blkg this request pool belongs to */#endif	/*	 * count[], starved[], and wait[] are indexed by	 * BLK_RW_SYNC/BLK_RW_ASYNC	 */	int			count[2];	int			starved[2];	mempool_t		*rq_pool;	wait_queue_head_t	wait[2];	unsigned int		flags;}; /* * request command types */enum rq_cmd_type_bits {	REQ_TYPE_FS		= 1,	/* fs request */	REQ_TYPE_BLOCK_PC,		/* scsi command */	REQ_TYPE_SENSE,			/* sense request */	REQ_TYPE_PM_SUSPEND,		/* suspend request */	REQ_TYPE_PM_RESUME,		/* resume request */	REQ_TYPE_PM_SHUTDOWN,		/* shutdown request */	REQ_TYPE_SPECIAL,		/* driver defined type */	/*	 * for ATA/ATAPI devices. this really doesn't belong here, ide should	 * use REQ_TYPE_SPECIAL and use rq->cmd[0] with the range of driver	 * private REQ_LB opcodes to differentiate what type of request this is	 */	REQ_TYPE_ATA_TASKFILE,	REQ_TYPE_ATA_PC,}; #define BLK_MAX_CDB	16 /* * try to put the fields that are referenced together in the same cacheline. * if you modify this structure, be sure to check block/blk-core.c:blk_rq_init() * as well! */struct request {	union {		struct list_head queuelist;		struct llist_node ll_list;	};	union {		struct call_single_data csd;		struct work_struct mq_flush_data;	}; 	struct request_queue *q;	struct blk_mq_ctx *mq_ctx; 	u64 cmd_flags;	enum rq_cmd_type_bits cmd_type;	unsigned long atomic_flags; 	int cpu; 	/* the following two fields are internal, NEVER access directly */	unsigned int __data_len;	/* total data len */	sector_t __sector;		/* sector cursor */ 	struct bio *bio;	struct bio *biotail; 	struct hlist_node hash;	/* merge hash */	/*	 * The rb_node is only used inside the io scheduler, requests	 * are pruned when moved to the dispatch queue. So let the	 * completion_data share space with the rb_node.	 */	union {		struct rb_node rb_node;	/* sort/lookup */		void *completion_data;	}; 	/*	 * Three pointers are available for the IO schedulers, if they need	 * more they have to dynamically allocate it.  Flush requests are	 * never put on the IO scheduler. So let the flush fields share	 * space with the elevator data.	 */	union {		struct {			struct io_cq		*icq;			void			*priv[2];		} elv; 		struct {			unsigned int		seq;			struct list_head	list;			rq_end_io_fn		*saved_end_io;		} flush;	}; 	struct gendisk *rq_disk;	struct hd_struct *part;	unsigned long start_time;#ifdef CONFIG_BLK_CGROUP	struct request_list *rl;		/* rl this rq is alloced from */	unsigned long long start_time_ns;	unsigned long long io_start_time_ns;    /* when passed to hardware */#endif	/* Number of scatter-gather DMA addr+len pairs after	 * physical address coalescing is performed.	 */	unsigned short nr_phys_segments;#if defined(CONFIG_BLK_DEV_INTEGRITY)	unsigned short nr_integrity_segments;#endif 	unsigned short ioprio; 	void *special;		/* opaque pointer available for LLD use */	char *buffer;		/* kaddr of the current segment if available */ 	int tag;	int errors; 	/*	 * when request is used as a packet command carrier	 */	unsigned char __cmd[BLK_MAX_CDB];	unsigned char *cmd;	unsigned short cmd_len; 	unsigned int extra_len;	/* length of alignment and padding */	unsigned int sense_len;	unsigned int resid_len;	/* residual count */	void *sense; 	unsigned long deadline;	struct list_head timeout_list;	unsigned int timeout;	int retries; 	/*	 * completion callback.	 */	rq_end_io_fn *end_io;	void *end_io_data; 	/* for bidi */	struct request *next_rq;}; static inline unsigned short req_get_ioprio(struct request *req){	return req->ioprio;} /* * State information carried for REQ_TYPE_PM_SUSPEND and REQ_TYPE_PM_RESUME * requests. Some step values could eventually be made generic. */struct request_pm_state{	/* PM state machine step value, currently driver specific */	int	pm_step;	/* requested PM state value (S1, S2, S3, S4, ...) */	u32	pm_state;	void*	data;		/* for driver use */}; #include <linux/elevator.h> struct blk_queue_ctx; typedef void (request_fn_proc) (struct request_queue *q);typedef void (make_request_fn) (struct request_queue *q, struct bio *bio);typedef int (prep_rq_fn) (struct request_queue *, struct request *);typedef void (unprep_rq_fn) (struct request_queue *, struct request *); struct bio_vec;struct bvec_merge_data {	struct block_device *bi_bdev;	sector_t bi_sector;	unsigned bi_size;	unsigned long bi_rw;};typedef int (merge_bvec_fn) (struct request_queue *, struct bvec_merge_data *,			     struct bio_vec *);typedef void (softirq_done_fn)(struct request *);typedef int (dma_drain_needed_fn)(struct request *);typedef int (lld_busy_fn) (struct request_queue *q);typedef int (bsg_job_fn) (struct bsg_job *); enum blk_eh_timer_return {	BLK_EH_NOT_HANDLED,	BLK_EH_HANDLED,	BLK_EH_RESET_TIMER,}; typedef enum blk_eh_timer_return (rq_timed_out_fn)(struct request *); enum blk_queue_state {	Queue_down,	Queue_up,}; struct blk_queue_tag {	struct request **tag_index;	/* map of busy tags */	unsigned long *tag_map;		/* bit map of free/busy tags */	int busy;			/* current depth */	int max_depth;			/* what we will send to device */	int real_max_depth;		/* what the array can hold */	atomic_t refcnt;		/* map can be shared */}; #define BLK_SCSI_MAX_CMDS	(256)#define BLK_SCSI_CMD_PER_LONG	(BLK_SCSI_MAX_CMDS / (sizeof(long) * 8)) struct queue_limits {	unsigned long		bounce_pfn;	unsigned long		seg_boundary_mask; 	unsigned int		max_hw_sectors;	unsigned int		max_sectors;	unsigned int		max_segment_size;	unsigned int		physical_block_size;	unsigned int		alignment_offset;	unsigned int		io_min;	unsigned int		io_opt;	unsigned int		max_discard_sectors;	unsigned int		max_write_same_sectors;	unsigned int		discard_granularity;	unsigned int		discard_alignment; 	unsigned short		logical_block_size;	unsigned short		max_segments;	unsigned short		max_integrity_segments; 	unsigned char		misaligned;	unsigned char		discard_misaligned;	unsigned char		cluster;	unsigned char		discard_zeroes_data;}; struct request_queue {	/*	 * Together with queue_head for cacheline sharing	 */	struct list_head	queue_head;	struct request		*last_merge;	struct elevator_queue	*elevator;	int			nr_rqs[2];	/* # allocated [a]sync rqs */	int			nr_rqs_elvpriv;	/* # allocated rqs w/ elvpriv */ 	/*	 * If blkcg is not used, @q->root_rl serves all requests.  If blkcg	 * is used, root blkg allocates from @q->root_rl and all other	 * blkgs from their own blkg->rl.  Which one to use should be	 * determined using bio_request_list().	 */	struct request_list	root_rl; 	request_fn_proc		*request_fn;	make_request_fn		*make_request_fn;	prep_rq_fn		*prep_rq_fn;	unprep_rq_fn		*unprep_rq_fn;	merge_bvec_fn		*merge_bvec_fn;	softirq_done_fn		*softirq_done_fn;	rq_timed_out_fn		*rq_timed_out_fn;	dma_drain_needed_fn	*dma_drain_needed;	lld_busy_fn		*lld_busy_fn; 	struct blk_mq_ops	*mq_ops; 	unsigned int		*mq_map; 	/* sw queues */	struct blk_mq_ctx	*queue_ctx;	unsigned int		nr_queues; 	/* hw dispatch queues */	struct blk_mq_hw_ctx	**queue_hw_ctx;	unsigned int		nr_hw_queues; 	/*	 * Dispatch queue sorting	 */	sector_t		end_sector;	struct request		*boundary_rq; 	/*	 * Delayed queue handling	 */	struct delayed_work	delay_work; 	struct backing_dev_info	backing_dev_info; 	/*	 * The queue owner gets to use this for whatever they like.	 * ll_rw_blk doesn't touch it.	 */	void			*queuedata; 	/*	 * various queue flags, see QUEUE_* below	 */	unsigned long		queue_flags; 	/*	 * ida allocated id for this queue.  Used to index queues from	 * ioctx.	 */	int			id; 	/*	 * queue needs bounce pages for pages above this limit	 */	gfp_t			bounce_gfp; 	/*	 * protects queue structures from reentrancy. ->__queue_lock should	 * _never_ be used directly, it is queue private. always use	 * ->queue_lock.	 */	spinlock_t		__queue_lock;	spinlock_t		*queue_lock; 	/*	 * queue kobject	 */	struct kobject kobj; 	/*	 * mq queue kobject	 */	struct kobject mq_kobj; #ifdef CONFIG_PM_RUNTIME	struct device		*dev;	int			rpm_status;	unsigned int		nr_pending;#endif 	/*	 * queue settings	 */	unsigned long		nr_requests;	/* Max # of requests */	unsigned int		nr_congestion_on;	unsigned int		nr_congestion_off;	unsigned int		nr_batching; 	unsigned int		dma_drain_size;	void			*dma_drain_buffer;	unsigned int		dma_pad_mask;	unsigned int		dma_alignment; 	struct blk_queue_tag	*queue_tags;	struct list_head	tag_busy_list; 	unsigned int		nr_sorted;	unsigned int		in_flight[2];	/*	 * Number of active block driver functions for which blk_drain_queue()	 * must wait. Must be incremented around functions that unlock the	 * queue_lock internally, e.g. scsi_request_fn().	 */	unsigned int		request_fn_active; 	unsigned int		rq_timeout;	struct timer_list	timeout;	struct list_head	timeout_list; 	struct list_head	icq_list;#ifdef CONFIG_BLK_CGROUP	DECLARE_BITMAP		(blkcg_pols, BLKCG_MAX_POLS);	struct blkcg_gq		*root_blkg;	struct list_head	blkg_list;#endif 	struct queue_limits	limits; 	/*	 * sg stuff	 */	unsigned int		sg_timeout;	unsigned int		sg_reserved_size;	int			node;#ifdef CONFIG_BLK_DEV_IO_TRACE	struct blk_trace	*blk_trace;#endif	/*	 * for flush operations	 */	unsigned int		flush_flags;	unsigned int		flush_not_queueable:1;	unsigned int		flush_queue_delayed:1;	unsigned int		flush_pending_idx:1;	unsigned int		flush_running_idx:1;	unsigned long		flush_pending_since;	struct list_head	flush_queue[2];	struct list_head	flush_data_in_flight;	union {		struct request	flush_rq;		struct {			spinlock_t mq_flush_lock;			struct work_struct mq_flush_work;		};	}; 	struct mutex		sysfs_lock; 	int			bypass_depth; #if defined(CONFIG_BLK_DEV_BSG)	bsg_job_fn		*bsg_job_fn;	int			bsg_job_size;	struct bsg_class_device bsg_dev;#endif #ifdef CONFIG_BLK_DEV_THROTTLING	/* Throttle data */	struct throtl_data *td;#endif	struct rcu_head		rcu_head;	wait_queue_head_t	mq_freeze_wq;	struct percpu_counter	mq_usage_counter;	struct list_head	all_q_node;}; #define QUEUE_FLAG_QUEUED	1	/* uses generic tag queueing */#define QUEUE_FLAG_STOPPED	2	/* queue is stopped */#define	QUEUE_FLAG_SYNCFULL	3	/* read queue has been filled */#define QUEUE_FLAG_ASYNCFULL	4	/* write queue has been filled */#define QUEUE_FLAG_DYING	5	/* queue being torn down */#define QUEUE_FLAG_BYPASS	6	/* act as dumb FIFO queue */#define QUEUE_FLAG_BIDI		7	/* queue supports bidi requests */#define QUEUE_FLAG_NOMERGES     8	/* disable merge attempts */#define QUEUE_FLAG_SAME_COMP	9	/* complete on same CPU-group */#define QUEUE_FLAG_FAIL_IO     10	/* fake timeout */#define QUEUE_FLAG_STACKABLE   11	/* supports request stacking */#define QUEUE_FLAG_NONROT      12	/* non-rotational device (SSD) */#define QUEUE_FLAG_VIRT        QUEUE_FLAG_NONROT /* paravirt device */#define QUEUE_FLAG_IO_STAT     13	/* do IO stats */#define QUEUE_FLAG_DISCARD     14	/* supports DISCARD */#define QUEUE_FLAG_NOXMERGES   15	/* No extended merges */#define QUEUE_FLAG_ADD_RANDOM  16	/* Contributes to random pool */#define QUEUE_FLAG_SECDISCARD  17	/* supports SECDISCARD */#define QUEUE_FLAG_SAME_FORCE  18	/* force complete on same CPU */#define QUEUE_FLAG_DEAD        19	/* queue tear-down finished */

Lines 1–500 of 1623.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t