Received: by 10.223.176.5 with SMTP id f5csp986093wra; Fri, 2 Feb 2018 09:16:26 -0800 (PST) X-Google-Smtp-Source: AH8x225CAA6YNcIA/LxzdtzySQuO7kTXWQoGrhyGWGkXyVdahuuZW4jmRBrTSGo4qSbuKVIfGC9Z X-Received: by 10.98.245.214 with SMTP id b83mr39817686pfm.85.1517591786053; Fri, 02 Feb 2018 09:16:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517591786; cv=none; d=google.com; s=arc-20160816; b=P6XBuolbZeiAm8hbf714YKSvg+JrnQL92cRciuBP2ywx6XCEWjt6Vyw5nZfxCsxnbK PIidtChQ3+HgRrcki2qurWGukcDbqlm3JzxUtXTi4IfG/ln4+8ZWnvw+KUS/t4Bp4Fh1 /IVtmQuJLQuYHfBC0zPAaZf0cTaBqB+vy4LIqGjF7sHVQ6GhajvcxXTlszgnRAyLYcNJ HF5bR6lq5r/0KwGLCr5ui2IUcVBNyFdfvHY0/SHin7iDtNNAGt6kitl0oNzH08GURMLa DqjYJykduQ5YUhw4QDihL1AvOLpZXOx1u90e1G5L6WRFtSRAvhXiqwDAXnsDx257IyiX x/pA== 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=o/yMhAJfS28dMdxEpF6BxKvQsyM9vgvUqGmxFw48GGs=; b=Hf0nJwChEWidBm1TsuvACXYrYVVRyoDCynN/bFnT6hpv1bNbaO1INoa09wjPncVo2T 0DxggS/lHFkDBLaMBrnESqi+N/ZJylroNCNDnY/qf27mE5BIYngGtZinMsvU/meNwL5M GNegvgeOqf0KhIoSMtjZT8UfXhlAR7TlP2i498WO7HZDXc0JH5GpWR019PZ8WTanvnSK JI23JBlQ4s7iiCEfTuOQZgj6M12mCqtECyTzfLDp4isCLQm2QWGduRr3EL8aMSl9OWjf Rw6ToZGA+bBV+jDryVSdnAPs7o7jtMgEjeuLFrEHamsUWACTOr88inkAeHGgVVo75nDJ 2NhA== 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 i14si1684805pgp.516.2018.02.02.09.16.10; Fri, 02 Feb 2018 09:16:26 -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 S1753731AbeBBRP3 (ORCPT + 99 others); Fri, 2 Feb 2018 12:15:29 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:37784 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753045AbeBBRJF (ORCPT ); Fri, 2 Feb 2018 12:09:05 -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 3E5CEDFF; Fri, 2 Feb 2018 17:09:04 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sagi Grimberg , Christoph Hellwig , Sasha Levin Subject: [PATCH 4.14 048/156] nvme-loop: check if queue is ready in queue_rq Date: Fri, 2 Feb 2018 17:57:09 +0100 Message-Id: <20180202140842.455058767@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 9d7fab04b95e8c26014a9bfc1c943b8360b44c17 ] 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_LOOP_Q_LIVE which is set after nvmf connect and cleared in queue teardown. Signed-off-by: Sagi Grimberg Signed-off-by: Christoph Hellwig Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/nvme/target/loop.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) --- a/drivers/nvme/target/loop.c +++ b/drivers/nvme/target/loop.c @@ -61,10 +61,15 @@ static inline struct nvme_loop_ctrl *to_ return container_of(ctrl, struct nvme_loop_ctrl, ctrl); } +enum nvme_loop_queue_flags { + NVME_LOOP_Q_LIVE = 0, +}; + struct nvme_loop_queue { struct nvmet_cq nvme_cq; struct nvmet_sq nvme_sq; struct nvme_loop_ctrl *ctrl; + unsigned long flags; }; static struct nvmet_port *nvmet_loop_port; @@ -153,6 +158,14 @@ nvme_loop_timeout(struct request *rq, bo return BLK_EH_HANDLED; } +static inline blk_status_t nvme_loop_is_ready(struct nvme_loop_queue *queue, + struct request *rq) +{ + if (unlikely(!test_bit(NVME_LOOP_Q_LIVE, &queue->flags))) + return nvmf_check_init_req(&queue->ctrl->ctrl, rq); + return BLK_STS_OK; +} + static blk_status_t nvme_loop_queue_rq(struct blk_mq_hw_ctx *hctx, const struct blk_mq_queue_data *bd) { @@ -162,6 +175,10 @@ static blk_status_t nvme_loop_queue_rq(s struct nvme_loop_iod *iod = blk_mq_rq_to_pdu(req); blk_status_t ret; + ret = nvme_loop_is_ready(queue, req); + if (unlikely(ret)) + return ret; + ret = nvme_setup_cmd(ns, req, &iod->cmd); if (ret) return ret; @@ -275,6 +292,7 @@ static const struct blk_mq_ops nvme_loop static void nvme_loop_destroy_admin_queue(struct nvme_loop_ctrl *ctrl) { + clear_bit(NVME_LOOP_Q_LIVE, &ctrl->queues[0].flags); nvmet_sq_destroy(&ctrl->queues[0].nvme_sq); blk_cleanup_queue(ctrl->ctrl.admin_q); blk_mq_free_tag_set(&ctrl->admin_tag_set); @@ -305,8 +323,10 @@ static void nvme_loop_destroy_io_queues( { int i; - for (i = 1; i < ctrl->ctrl.queue_count; i++) + for (i = 1; i < ctrl->ctrl.queue_count; i++) { + clear_bit(NVME_LOOP_Q_LIVE, &ctrl->queues[i].flags); nvmet_sq_destroy(&ctrl->queues[i].nvme_sq); + } } static int nvme_loop_init_io_queues(struct nvme_loop_ctrl *ctrl) @@ -346,6 +366,7 @@ static int nvme_loop_connect_io_queues(s ret = nvmf_connect_io_queue(&ctrl->ctrl, i); if (ret) return ret; + set_bit(NVME_LOOP_Q_LIVE, &ctrl->queues[i].flags); } return 0; @@ -387,6 +408,8 @@ static int nvme_loop_configure_admin_que if (error) goto out_cleanup_queue; + set_bit(NVME_LOOP_Q_LIVE, &ctrl->queues[0].flags); + error = nvmf_reg_read64(&ctrl->ctrl, NVME_REG_CAP, &ctrl->ctrl.cap); if (error) { dev_err(ctrl->ctrl.device,