调用blk_mq_rq_ctx_init 初始化tag对应的request(tags->static_rqs[tag]) 图8. blk-mq bio提交时request分配流程 request_queue初始化 基于blk-mq的块设备驱动初始化时,通过调用blk_mq_init_queue初始化IO请求队列(request_queue)。例如,scsi-mq驱动中,每次添加scsi设备(scsi_device)时都会调用blk_mq_init_qu...
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); if (!uninit_q) return NULL; q = blk_init_allocated_queue(uninit_q, rfn, lock); if (!q) blk_cleanup_queue...
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_...
对应到代码per_cpu_ptr(q->queue_ctx, cpu) 一个ctx根据rq type不同可以对应到多个hctx上, 但同一type的ctx只会有一个hctx. 显然rq知道知己的type, 所以rq映射到唯一的一个hctx上, 具体代码见blk_mq_get_request/blk_mq_map_queue. 这里的核心思想是对于读操作或者高优先级的rq, 可以使用单独的hctx ...
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 ...
blk_mq_clear_flush_rq_mapping(set->tags[hctx_idx], set->queue_depth,flush_rq); if(blk_queue_init_done(q)) blk_mq_clear_flush_rq_mapping(set->tags[hctx_idx], set->queue_depth,flush_rq); if(set->ops->exit_request) set->ops->exit_request(set,flush_rq,hctx_idx); ...
* If you modify this structure, make sure to update blk_rq_init() and * especially blk_mq_rq_ctx_init() to take care of the added fields.*/structrequest {structrequest_queue *q;structblk_mq_ctx *mq_ctx;structblk_mq_hw_ctx *mq_hctx; ...
> > EXPORT_SYMBOL(blk_mq_init_allocated_queue); > > -void blk_mq_free_queue(struct request_queue *q) > > +/* tags can _not_ be used after returning from blk_mq_exit_queue */ > > +void blk_mq_exit_queue(struct request_queue *q) ...
q = blk_mq_init_queue(&vblk->tag_set); if (IS_ERR(q)) { err = -ENOMEM; goto out_free_tags; } vblk->disk->queue = q; q->queuedata = vblk; virtblk_name_format("vd", index, vblk->disk->disk_name, DISK_NAME_LEN); vblk->disk->major = major; vblk->di...
> > @@ -2854,6 +2865,9 @@ struct request_queue > > *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set, > > if (!q->queue_hw_ctx) > > goto err_sys_init; > > + INIT_LIST_HEAD(&q->dead_hctx_list); > > + spin_lock_init(&q->dead_hctx_lock); ...