drivers/md/dm-rq.c
Source file repositories/reference/linux-study-clean/drivers/md/dm-rq.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/md/dm-rq.c- Extension
.c- Size
- 15767 bytes
- Lines
- 609
- Domain
- Driver Families
- Bucket
- drivers/md
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
dm-core.hdm-rq.hlinux/blk-mq.h
Detected Declarations
struct dm_rq_target_iofunction dm_get_reserved_rq_based_iosfunction dm_get_blk_mq_nr_hw_queuesfunction dm_get_blk_mq_queue_depthfunction dm_request_basedfunction dm_start_queuefunction dm_stop_queuefunction end_clone_biofunction rq_end_statsfunction dm_putfunction end_clone_requestfunction __dm_mq_kick_requeue_listfunction dm_mq_kick_requeue_listfunction dm_mq_delay_requeue_requestfunction dm_requeue_original_requestfunction dm_donefunction dm_softirq_donefunction dm_complete_requestfunction dm_kill_unmapped_requestfunction end_clone_requestfunction dm_rq_bio_constructorfunction setup_clonefunction init_tiofunction map_requestfunction dm_attr_rq_based_seq_io_merge_deadline_showfunction dm_attr_rq_based_seq_io_merge_deadline_storefunction dm_start_requestfunction dm_mq_init_requestfunction dm_mq_queue_rqfunction dm_mq_init_request_queuefunction dm_mq_cleanup_mapped_deviceexport dm_mq_kick_requeue_list
Annotated Snippet
static const struct blk_mq_ops dm_mq_ops = {
.queue_rq = dm_mq_queue_rq,
.complete = dm_softirq_done,
.init_request = dm_mq_init_request,
};
int dm_mq_init_request_queue(struct mapped_device *md, struct dm_table *t)
{
struct dm_target *immutable_tgt;
int err;
md->tag_set = kzalloc_node(sizeof(struct blk_mq_tag_set), GFP_KERNEL, md->numa_node_id);
if (!md->tag_set)
return -ENOMEM;
md->tag_set->ops = &dm_mq_ops;
md->tag_set->queue_depth = dm_get_blk_mq_queue_depth();
md->tag_set->numa_node = md->numa_node_id;
md->tag_set->flags = BLK_MQ_F_STACKING;
md->tag_set->nr_hw_queues = dm_get_blk_mq_nr_hw_queues();
md->tag_set->driver_data = md;
md->tag_set->cmd_size = sizeof(struct dm_rq_target_io);
immutable_tgt = dm_table_get_immutable_target(t);
if (immutable_tgt && immutable_tgt->per_io_data_size) {
/* any target-specific per-io data is immediately after the tio */
md->tag_set->cmd_size += immutable_tgt->per_io_data_size;
md->init_tio_pdu = true;
}
err = blk_mq_alloc_tag_set(md->tag_set);
if (err)
goto out_kfree_tag_set;
err = blk_mq_init_allocated_queue(md->tag_set, md->queue);
if (err)
goto out_tag_set;
return 0;
out_tag_set:
blk_mq_free_tag_set(md->tag_set);
out_kfree_tag_set:
kfree(md->tag_set);
md->tag_set = NULL;
return err;
}
void dm_mq_cleanup_mapped_device(struct mapped_device *md)
{
if (md->tag_set) {
blk_mq_free_tag_set(md->tag_set);
kfree(md->tag_set);
md->tag_set = NULL;
}
}
module_param(reserved_rq_based_ios, uint, 0644);
MODULE_PARM_DESC(reserved_rq_based_ios, "Reserved IOs in request-based mempools");
/* Unused, but preserved for userspace compatibility */
static bool use_blk_mq = true;
module_param(use_blk_mq, bool, 0644);
MODULE_PARM_DESC(use_blk_mq, "Use block multiqueue for request-based DM devices");
module_param(dm_mq_nr_hw_queues, uint, 0644);
MODULE_PARM_DESC(dm_mq_nr_hw_queues, "Number of hardware queues for request-based dm-mq devices");
module_param(dm_mq_queue_depth, uint, 0644);
MODULE_PARM_DESC(dm_mq_queue_depth, "Queue depth for request-based dm-mq devices");
Annotation
- Immediate include surface: `dm-core.h`, `dm-rq.h`, `linux/blk-mq.h`.
- Detected declarations: `struct dm_rq_target_io`, `function dm_get_reserved_rq_based_ios`, `function dm_get_blk_mq_nr_hw_queues`, `function dm_get_blk_mq_queue_depth`, `function dm_request_based`, `function dm_start_queue`, `function dm_stop_queue`, `function end_clone_bio`, `function rq_end_stats`, `function dm_put`.
- Atlas domain: Driver Families / drivers/md.
- Implementation status: pattern implementation candidate.
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.