linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: hch@infradead.org ('Christoph Hellwig')
Subject: crash when connecting to targets using nr_io_queues < num cpus
Date: Thu, 22 Sep 2016 14:02:55 -0700	[thread overview]
Message-ID: <20160922210255.GA11015@infradead.org> (raw)
In-Reply-To: <20160916142649.GA18798@infradead.org>

Steve,

can you test if the patch below properly fails the connect and avoids
the crash?

We could potentially also do something better than just returning the
error in that case.  From a quick look at the code even just ignoring
a EXDEV return from nvmf_connect_io_queue might do the right thing,
so feel free to try that if you have some spare cycles.

---
>From d76be818600d92341125b7c78dcab780a9833427 Mon Sep 17 00:00:00 2001
From: Christoph Hellwig <hch@lst.de>
Date: Thu, 22 Sep 2016 13:56:54 -0700
Subject: blk-mq: skip unmapped queues in blk_mq_alloc_request_hctx

This provides the caller a feedback that a given hctx is not mapped and thus
no command can be sent on it.

Signed-off-by: Christoph Hellwig <hch at lst.de>
---
 block/blk-mq.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index e9b8007..7b430ab 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -266,17 +266,29 @@ struct request *blk_mq_alloc_request_hctx(struct request_queue *q, int rw,
 	if (ret)
 		return ERR_PTR(ret);
 
+	/*
+	 * Check if the hardware context is actually mapped to anything.
+	 * If not tell the caller that it should skip this queue.
+	 */
 	hctx = q->queue_hw_ctx[hctx_idx];
+	if (!blk_mq_hw_queue_mapped(hctx)) {
+		ret = -EXDEV;
+		goto out_queue_exit;
+	}
 	ctx = __blk_mq_get_ctx(q, cpumask_first(hctx->cpumask));
 
 	blk_mq_set_alloc_data(&alloc_data, q, flags, ctx, hctx);
 	rq = __blk_mq_alloc_request(&alloc_data, rw, 0);
 	if (!rq) {
-		blk_queue_exit(q);
-		return ERR_PTR(-EWOULDBLOCK);
+		ret = -EWOULDBLOCK;
+		goto out_queue_exit;
 	}
 
 	return rq;
+
+out_queue_exit:
+	blk_queue_exit(q);
+	return ERR_PTR(ret);
 }
 EXPORT_SYMBOL_GPL(blk_mq_alloc_request_hctx);
 
-- 
2.1.4

  reply	other threads:[~2016-09-22 21:02 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-31 20:12 crash when connecting to targets using nr_io_queues < num cpus Steve Wise
2016-09-01  9:32 ` Sagi Grimberg
2016-09-01 14:10   ` Steve Wise
2016-09-01 19:01     ` Steve Wise
2016-09-04  8:46       ` Sagi Grimberg
2016-09-13 14:21         ` Steve Wise
2016-09-13 17:14           ` Ming Lin
2016-09-13 17:52           ` Keith Busch
2016-09-13 19:43             ` Steve Wise
2016-09-16 14:10             ` Steve Wise
2016-09-16 14:26               ` 'Christoph Hellwig'
2016-09-22 21:02                 ` 'Christoph Hellwig' [this message]
2016-09-22 21:38                   ` Steve Wise
2016-09-22 21:48                     ` 'Christoph Hellwig'
2016-09-22 22:03                       ` Steve Wise
     [not found]                       ` <024201d2151d$28013b90$7803b2b0$@opengridcomputing.com>
2016-09-23  0:01                         ` Steve Wise
2016-09-23  3:31                           ` 'Christoph Hellwig'
2016-09-23 13:58                             ` Steve Wise
2016-09-23 16:21                             ` Jens Axboe
2016-09-23 16:23                               ` 'Christoph Hellwig'
2016-09-23 16:24                                 ` Jens Axboe
2016-09-23 16:26                                   ` Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160922210255.GA11015@infradead.org \
    --to=hch@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).