staticintramblock_init(void){/* 1. 分配一个gendisk结构体 */ramblock_disk = alloc_disk(16);/* 次设备号个数: 分区个数+1 *//* 2. 设置 *//* 2.1 分配/设置队列: 提供读写能力 */ramblock_queue =blk_init_queue(do_ramblock_request, &ramblock_lock); ramblock_disk->queue= ramblock_...
return blk_init_queue_node(rfn, lock, NUMA_NO_NODE); } EXPORT_SYMBOL(blk_init_queue); struct request_queue * blk_init_queue_node(request_fn_proc *rfn, spinlock_t *lock, int node_id) { struct request_queue *uninit_q, *q; uninit_q = blk_alloc_queue_node(GFP_KERNEL, node_id); ...
分析: /**blk_plug permits building a queue of related requests by holding the I/O* fragments for a short period. This allows merging of sequential requests* into single larger request. As the requests are moved from a per-task list to* the device's request_queue in a batch, this resul...
*/intmmc_init_queue(struct mmc_queue *mq, struct mmc_card *card,spinlock_t*lock){structmmc_host*host=card->host;u64 limit = BLK_BOUNCE_HIGH;intret;if(host->dev->dma_mask && *host->dev->dma_mask) limit = *host->dev->dma_mask; mq->card = card; mq->queue= blk_init_queue(...
If the elevator init function called with error return, it will run into the fail case to free the q->fq. Then the __blk_drain_queue() uses the same memory after the free of the q->fq, it will lead to the unpredictable event. The patch is to set q->fq as NULL in the fail ...
第一个成员queue_rq指定blk-mq向驱动提交request的函数,第二个map_queue定义如何将software queue和hardware queue对应,第三个init_hctx是hardware Queue创建时调用(可以在这里将NVMe Queue与Hardware Queue绑定),init_request是在分配Request时调用,timeout是发生timeout时的调用。这些函数都是供blk-mq使用的。
在virtblk_probe 中,我们首先看到的是 struct request_queue,这是每一个块设备都有的一个队列。还记得吗?它有两个函数,一个是 make_request_fn 函数,用于生成 request;另一个是 request_fn 函数,用于处理 request。 这个request_queue 的初始化过程在 blk_mq_init_queue 中。它会调用 blk_mq_init_allocated...
{ struct request_queue *q = hctx->queue; struct deadline_data *dd = q->elevator->elevator_data; spin_lock(&dd->lock); while (!list_empty(list)) { struct request *rq; rq = list_first_entry(list, struct request, queuelist); list_del_init(&rq->queuelist); dd_insert_request(h...
@@ -2220,16 +2221,11 @@ static void blk_mq_init_cpu_queues(struct request_queue *q, INIT_LIST_HEAD(&__ctx->rq_list); __ctx->queue = q;/* If the cpu isn't present, the cpu is mapped to first hctx */ if (!cpu_present(i)) ...
继续搜索blk_queue_make_request,找到它被谁调用,赋入的mfn参数是什么 如下图,找到它在blk_init_queue_node()函数中被调用 ? ...(do_xd_request, &xd_lock); //分配一个申请队列 其中blk_init_queue()函数原型如下所示: request_queue *blk_init_queue... #include #include #...