include/linux/blk-mq.h
Source file repositories/reference/linux-study-clean/include/linux/blk-mq.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/blk-mq.h- Extension
.h- Size
- 37497 bytes
- Lines
- 1296
- Domain
- Representative Device Path
- Bucket
- PCIe NVMe Storage Path
- Inferred role
- Representative Device Path: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
Part of the selected hardware vertical slice: PCI discovery, driver binding, NVMe queues, block requests, DMA, interrupts, and completion.
- Part of the selected hardware vertical slice: PCI discovery, driver binding, NVMe queues, block requests, DMA, interrupts, and completion.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/blkdev.hlinux/sbitmap.hlinux/lockdep.hlinux/scatterlist.hlinux/prefetch.hlinux/srcu.hlinux/rw_hint.hlinux/rwsem.h
Detected Declarations
struct blk_mq_tagsstruct blk_flush_queuestruct io_comp_batchstruct requeststruct blk_mq_hw_ctxstruct blk_mq_queue_mapstruct blk_mq_tag_setstruct blk_mq_queue_datastruct blk_mq_opsstruct blk_mq_tagsstruct rq_map_datastruct req_iteratorenum rq_end_io_retenum rqf_flagsenum mq_rq_stateenum blk_eh_timer_returnenum hctx_typefunction req_phys_gap_maskfunction req_opfunction blk_rq_is_passthroughfunction req_get_iopriofunction rq_list_emptyfunction rq_list_initfunction rq_list_add_tailfunction rq_list_add_headfunction blk_mq_unique_tag_to_hwqfunction blk_mq_unique_tag_to_tagfunction blk_mq_rq_statefunction blk_mq_request_startedfunction blk_mq_request_completedfunction blk_mq_set_request_completefunction blk_mq_complete_request_directfunction blk_mq_need_time_stampfunction blk_mq_is_reserved_rqfunction blk_mq_add_to_batchfunction blk_mq_freeze_queuefunction blk_mq_unfreeze_queuefunction blk_should_fake_timeoutfunction blk_mq_cleanup_rqfunction rq_is_syncfunction bio_for_each_segmentfunction blk_rq_bytesfunction blk_rq_has_datafunction blk_rq_cur_bytesfunction blk_rq_sectorsfunction blk_rq_cur_sectorsfunction blk_rq_stats_sectorsfunction blk_rq_payload_bytes
Annotated Snippet
const struct blk_mq_ops *ops;
struct blk_mq_queue_map map[HCTX_MAX_TYPES];
unsigned int nr_maps;
unsigned int nr_hw_queues;
unsigned int queue_depth;
unsigned int reserved_tags;
unsigned int cmd_size;
int numa_node;
unsigned int timeout;
unsigned int flags;
void *driver_data;
struct blk_mq_tags **tags;
struct blk_mq_tags *shared_tags;
struct mutex tag_list_lock;
struct list_head tag_list;
struct srcu_struct *srcu;
struct srcu_struct tags_srcu;
struct rw_semaphore update_nr_hwq_lock;
};
/**
* struct blk_mq_queue_data - Data about a request inserted in a queue
*
* @rq: Request pointer.
* @last: If it is the last request in the queue.
*/
struct blk_mq_queue_data {
struct request *rq;
bool last;
};
typedef bool (busy_tag_iter_fn)(struct request *, void *);
/**
* struct blk_mq_ops - Callback functions that implements block driver
* behaviour.
*/
struct blk_mq_ops {
/**
* @queue_rq: Queue a new request from block IO.
*/
blk_status_t (*queue_rq)(struct blk_mq_hw_ctx *,
const struct blk_mq_queue_data *);
/**
* @commit_rqs: If a driver uses bd->last to judge when to submit
* requests to hardware, it must define this function. In case of errors
* that make us stop issuing further requests, this hook serves the
* purpose of kicking the hardware (which the last request otherwise
* would have done).
*/
void (*commit_rqs)(struct blk_mq_hw_ctx *);
/**
* @queue_rqs: Queue a list of new requests. Driver is guaranteed
* that each request belongs to the same queue. If the driver doesn't
* empty the @rqlist completely, then the rest will be queued
* individually by the block layer upon return.
*/
void (*queue_rqs)(struct rq_list *rqlist);
/**
* @get_budget: Reserve budget before queue request, once .queue_rq is
* run, it is driver's responsibility to release the
* reserved budget. Also we have to handle failure case
* of .get_budget for avoiding I/O deadlock.
*/
int (*get_budget)(struct request_queue *);
/**
* @put_budget: Release the reserved budget.
*/
void (*put_budget)(struct request_queue *, int);
/**
* @set_rq_budget_token: store rq's budget token
*/
void (*set_rq_budget_token)(struct request *, int);
/**
* @get_rq_budget_token: retrieve rq's budget token
*/
int (*get_rq_budget_token)(struct request *);
/**
* @timeout: Called on request timeout.
*/
Annotation
- Immediate include surface: `linux/blkdev.h`, `linux/sbitmap.h`, `linux/lockdep.h`, `linux/scatterlist.h`, `linux/prefetch.h`, `linux/srcu.h`, `linux/rw_hint.h`, `linux/rwsem.h`.
- Detected declarations: `struct blk_mq_tags`, `struct blk_flush_queue`, `struct io_comp_batch`, `struct request`, `struct blk_mq_hw_ctx`, `struct blk_mq_queue_map`, `struct blk_mq_tag_set`, `struct blk_mq_queue_data`, `struct blk_mq_ops`, `struct blk_mq_tags`.
- Atlas domain: Representative Device Path / PCIe NVMe Storage Path.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.