blk-mq: don't allow queue entering for a dying queue
[deliverable/linux.git] / block / blk-mq.c
index 4e4cd62080524bf05644cfc59c78218d3a2c4a98..75fc33f342516c883231ca16b3c2129ff386a624 100644 (file)
@@ -82,8 +82,10 @@ static int blk_mq_queue_enter(struct request_queue *q)
 
        __percpu_counter_add(&q->mq_usage_counter, 1, 1000000);
        smp_wmb();
-       /* we have problems to freeze the queue if it's initializing */
-       if (!blk_queue_bypass(q) || !blk_queue_init_done(q))
+
+       /* we have problems freezing the queue if it's initializing */
+       if (!blk_queue_dying(q) &&
+           (!blk_queue_bypass(q) || !blk_queue_init_done(q)))
                return 0;
 
        __percpu_counter_add(&q->mq_usage_counter, -1, 1000000);
@@ -1967,13 +1969,19 @@ static int blk_mq_queue_reinit_notify(struct notifier_block *nb,
        return NOTIFY_OK;
 }
 
+/*
+ * 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 if it 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 i;
 
        if (!set->nr_hw_queues)
                return -EINVAL;
-       if (!set->queue_depth || set->queue_depth > BLK_MQ_MAX_DEPTH)
+       if (!set->queue_depth)
                return -EINVAL;
        if (set->queue_depth < set->reserved_tags + BLK_MQ_TAG_MIN)
                return -EINVAL;
@@ -1981,6 +1989,11 @@ int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set)
        if (!set->nr_hw_queues || !set->ops->queue_rq || !set->ops->map_queue)
                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;
+       }
 
        set->tags = kmalloc_node(set->nr_hw_queues *
                                 sizeof(struct blk_mq_tags *),
This page took 0.029128 seconds and 5 git commands to generate.