Received: by 10.223.176.5 with SMTP id f5csp1037777wra; Fri, 2 Feb 2018 10:06:01 -0800 (PST) X-Google-Smtp-Source: AH8x226N5AP59+V43z0pRh19tOYvF7SLk8ZDKVabIMl97sUSOuoWoE7dm0vAaOWrzFCIYLq4/DT5 X-Received: by 10.98.63.15 with SMTP id m15mr5990718pfa.221.1517594761231; Fri, 02 Feb 2018 10:06:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517594761; cv=none; d=google.com; s=arc-20160816; b=xfTOxiXVAMH2SLLZcSyX271aVV9kS0vtNwuS7wyt6RiJn8Y21SIvpUbS8gM8HYFqKz bx1bI1q9xae2bz8xwPTOdL47PbxwjLovwmQfLlcDxkxTFpC58IxJx7YrGc5mz2bDQ4wc p45zAa7yuVR+FF7p+pZRHbIuXHHyIcBueBwVlazYD0YqirXTHg5hcP0MZ4B/vUW1l6G7 w/rYCzcRfpw1yIkgFDq5ZXd93haBFyriYnszv1Zuv6xsqpTReHymSiSjZRzNzf5nAoH3 5TyvzNUEyTe2HVvsIfCA6uCsAqskI8zBt9YshxiaGPTSen+eLoVtovl2cILKbtoOlmm4 Q6+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=RFoo1pW/eOz9oI5U6AjzWMbmhJ0x+mlncc9HLMf7Duw=; b=IWt1SLH8OV9v5N7g3j9nSbM4Dh5sFk5UQkPAf3zJ1rg0NI7Ipy42Cd/FNPqyeqUCLd x95qCDtJtxb7FrmN0ae4MR6aycWPiTD2NcfC/JqnBnrfnpTlbqfh+4V7rDPwBrKhvQRH pHxAHkEp6KvuCOKzq+YAFIGb6o/HiIfehtv3XDUh4jlmtiMYm/+XV2DVFPPMe3CfsL8M sWrrgzgRGSNrC/Kc61A98WJfpBp6Z6GQwO4KVVF3SfK9V1jE1bc45bcr5zhAtzgD6RhI uLITr8sxRo1L9M6A0s4aq9RROKxhgFGmsNrUgC7KZWmJBoumNSUcreL/YoEPZ/jK7ie9 9SIw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e3si205224pfi.191.2018.02.02.10.05.45; Fri, 02 Feb 2018 10:06:01 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753057AbeBBSDb (ORCPT + 99 others); Fri, 2 Feb 2018 13:03:31 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:37766 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752920AbeBBRJC (ORCPT ); Fri, 2 Feb 2018 12:09:02 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 8899BDE5; Fri, 2 Feb 2018 17:09:01 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sagi Grimberg , James Smart , Christoph Hellwig , Sasha Levin Subject: [PATCH 4.14 047/156] nvme-fc: check if queue is ready in queue_rq Date: Fri, 2 Feb 2018 17:57:08 +0100 Message-Id: <20180202140842.408782073@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180202140840.242829545@linuxfoundation.org> References: <20180202140840.242829545@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sagi Grimberg [ Upstream commit 9e0ed16ab9a9aaf670b81c9cd05b5e50defed654 ] In case the queue is not LIVE (fully functional and connected at the nvmf level), we cannot allow any commands other than connect to pass through. Add a new queue state flag NVME_FC_Q_LIVE which is set after nvmf connect and cleared in queue teardown. Signed-off-by: Sagi Grimberg Reviewed-by: James Smart Signed-off-by: Christoph Hellwig Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/nvme/host/fc.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) --- a/drivers/nvme/host/fc.c +++ b/drivers/nvme/host/fc.c @@ -41,6 +41,7 @@ enum nvme_fc_queue_flags { NVME_FC_Q_CONNECTED = (1 << 0), + NVME_FC_Q_LIVE = (1 << 1), }; #define NVMEFC_QUEUE_DELAY 3 /* ms units */ @@ -1654,6 +1655,7 @@ nvme_fc_free_queue(struct nvme_fc_queue if (!test_and_clear_bit(NVME_FC_Q_CONNECTED, &queue->flags)) return; + clear_bit(NVME_FC_Q_LIVE, &queue->flags); /* * Current implementation never disconnects a single queue. * It always terminates a whole association. So there is never @@ -1661,7 +1663,6 @@ nvme_fc_free_queue(struct nvme_fc_queue */ queue->connection_id = 0; - clear_bit(NVME_FC_Q_CONNECTED, &queue->flags); } static void @@ -1740,6 +1741,8 @@ nvme_fc_connect_io_queues(struct nvme_fc ret = nvmf_connect_io_queue(&ctrl->ctrl, i); if (ret) break; + + set_bit(NVME_FC_Q_LIVE, &ctrl->queues[i].flags); } return ret; @@ -2048,6 +2051,14 @@ busy: return BLK_STS_RESOURCE; } +static inline blk_status_t nvme_fc_is_ready(struct nvme_fc_queue *queue, + struct request *rq) +{ + if (unlikely(!test_bit(NVME_FC_Q_LIVE, &queue->flags))) + return nvmf_check_init_req(&queue->ctrl->ctrl, rq); + return BLK_STS_OK; +} + static blk_status_t nvme_fc_queue_rq(struct blk_mq_hw_ctx *hctx, const struct blk_mq_queue_data *bd) @@ -2063,6 +2074,10 @@ nvme_fc_queue_rq(struct blk_mq_hw_ctx *h u32 data_len; blk_status_t ret; + ret = nvme_fc_is_ready(queue, rq); + if (unlikely(ret)) + return ret; + ret = nvme_setup_cmd(ns, rq, sqe); if (ret) return ret; @@ -2398,6 +2413,8 @@ nvme_fc_create_association(struct nvme_f if (ret) goto out_disconnect_admin_queue; + set_bit(NVME_FC_Q_LIVE, &ctrl->queues[0].flags); + /* * Check controller capabilities *