linux/block/blk-mq.c
/*
 * Alloc a tag set to be associated with one or more request queues.
 * May fail with EINVAL for various error conditions. May adjust the
 * requested depth down, if it's too large. In that case, the set
 * value will be stored in set->queue_depth.
 */
Alloc a tag set to be associated with one or more request queues.
May fail with EINVAL for various error conditions. May adjust the
requested depth down, if it's too large. In that case, the set
value will be stored in set->queue_depth.
Alloc a tag set to be associated with one or more request queues . May fail with EINVAL for various error conditions . May adjust the requested depth down if it ' s too large . In that case the set value will be stored in set - > queue_depth .
int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set)
{
	int ret;
	BUILD_BUG_ON(BLK_MQ_MAX_DEPTH > 1 << BLK_MQ_UNIQUE_TAG_BITS);
	if (!set->nr_hw_queues)
		return -EINVAL;
	if (!set->queue_depth)
		return -EINVAL;
	if (set->queue_depth < set->reserved_tags + BLK_MQ_TAG_MIN)
		return -EINVAL;
	if (!set->ops->queue_rq)
		return -EINVAL;
	if (!set->ops->get_budget ^ !set->ops->put_budget)
		return -EINVAL;
	if (set->queue_depth > BLK_MQ_MAX_DEPTH) {
		pr_info("blk-mq: reduced tag depth to %u\n",
			BLK_MQ_MAX_DEPTH);
		set->queue_depth = BLK_MQ_MAX_DEPTH;
	}
	if (is_kdump_kernel()) {
		set->nr_hw_queues = 1;
		set->queue_depth = min(64U, set->queue_depth);
	}
	if (set->nr_hw_queues > nr_cpu_ids)
		set->nr_hw_queues = nr_cpu_ids;
	set->tags = kcalloc_node(nr_cpu_ids, sizeof(struct blk_mq_tags *),
				 GFP_KERNEL, set->numa_node);
	if (!set->tags)
		return -ENOMEM;
	ret = -ENOMEM;
	set->mq_map = kcalloc_node(nr_cpu_ids, sizeof(*set->mq_map),
				   GFP_KERNEL, set->numa_node);
	if (!set->mq_map)
		goto out_free_tags;
	ret = blk_mq_update_queue_map(set);
	if (ret)
		goto out_free_mq_map;
	ret = blk_mq_alloc_rq_maps(set);
	if (ret)
		goto out_free_mq_map;
	mutex_init(&set->tag_list_lock);
	INIT_LIST_HEAD(&set->tag_list);
	return 0;
out_free_mq_map:
	kfree(set->mq_map);
	set->mq_map = NULL;
out_free_tags:
	kfree(set->tags);
	set->tags = NULL;
	return ret;
}
int blk_mq_alloc_tag_set ( struct blk_mq_tag_set * set ) { int ret ; BUILD_BUG_ON ( BLK_MQ_MAX_DEPTH > 1 << BLK_MQ_UNIQUE_TAG_BITS ) ; if ( ! set -> nr_hw_queues ) return - EINVAL ; if ( ! set -> queue_depth ) return - EINVAL ; if ( set -> queue_depth < set -> reserved_tags + BLK_MQ_TAG_MIN ) return - EINVAL ; if ( ! set -> ops -> queue_rq ) return - EINVAL ; if ( ! set -> ops -> get_budget ^ ! set -> ops -> put_budget ) return - EINVAL ; if ( set -> queue_depth > BLK_MQ_MAX_DEPTH ) { pr_info ( " \n " , BLK_MQ_MAX_DEPTH ) ; set -> queue_depth = BLK_MQ_MAX_DEPTH ; } if ( is_kdump_kernel ( ) ) { set -> nr_hw_queues = 1 ; set -> queue_depth = min ( 64U , set -> queue_depth ) ; } if ( set -> nr_hw_queues > nr_cpu_ids ) set -> nr_hw_queues = nr_cpu_ids ; set -> tags = kcalloc_node ( nr_cpu_ids , sizeof ( struct blk_mq_tags * ) , GFP_KERNEL , set -> numa_node ) ; if ( ! set -> tags ) return - ENOMEM ; ret = - ENOMEM ; set -> mq_map = kcalloc_node ( nr_cpu_ids , sizeof ( * set -> mq_map ) , GFP_KERNEL , set -> numa_node ) ; if ( ! set -> mq_map ) goto out_free_tags ; ret = blk_mq_update_queue_map ( set ) ; if ( ret ) goto out_free_mq_map ; ret = blk_mq_alloc_rq_maps ( set ) ; if ( ret ) goto out_free_mq_map ; mutex_init ( & set -> tag_list_lock ) ; INIT_LIST_HEAD ( & set -> tag_list ) ; return 0 ; out_free_mq_map : kfree ( set -> mq_map ) ; set -> mq_map = NULL ; out_free_tags : kfree ( set -> tags ) ; set -> tags = NULL ; return ret ; }
Alloc a tag set to be associated with one or more request queues.
Alloc a tag set to be associated with one or more request queues .
/*
	 * If a crashdump is active, then we are potentially in a very
	 * memory constrained environment. Limit us to 1 queue and
	 * 64 tags to prevent using too much memory.
	 */ /*
	 * There is no use for more h/w queues than cpus.
	 */