Received: by 10.223.176.5 with SMTP id f5csp1038134wra; Fri, 2 Feb 2018 10:06:18 -0800 (PST) X-Google-Smtp-Source: AH8x2258hLt/OPk+0zymCTLwq0Lfzkp11DNb7w31Ge455n6vMVx0TPyQBJERfZYH5gGjEfD9PZfo X-Received: by 10.101.80.72 with SMTP id k8mr30836556pgo.361.1517594778687; Fri, 02 Feb 2018 10:06:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517594778; cv=none; d=google.com; s=arc-20160816; b=fJDewcmFFyTBgO05X5kPk3rcr3N/q4XrBWw06NHci8ScMBgCl7wE/k6rB1D5NuFG3H kY5g2klRB0CFZOyrIKkiWFIKVvRlK6LtFf/QLPoGqMheDdCYRmkm60jqILK8ulJn7JVs xun3HTwmOuv+Xiauu12FYjC9xP9OqwZELPvbyrhXDa8JhIlTkyrSQ19+NhnIy3HtiJPb lImfUFe48raWsFazpS8Zefap/zU6oTW0u8gnGVsNMU8nOQfSJQljz+7sNyws9fhaDdWr mhjFM5f2RUhbH6jLHLaCSuL+Rgd8WVX2C52oO54IM93vs8bUL/MakUkwVJTVCYZncUoa Zm8w== 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=TpS6mtTKZFk7vcmP4mBfigAk2vsvS4UUp4ctNHNMMbQ=; b=cXT9K42j0OBgmIPaczmavRZoUTCuLmfZzHGqSctrgfA9C4UJgm5sOqI+B65zb2OrzG vOTs4dYkgBdEl+oAKJc77lT7u0v3K0vErelZDOTz6eRbNZeg1IfXfrAHh51fgrvRr038 WA220sgur1m6Tf73PK4RkN5Nt5kIYaeGdpVZK5zs7zmWp7qlM5wKG3xZvvms7tRzRBj2 VNUb8+eMpLCbBjL4JPFcUjMugAbTHjR8Hm2PCx9yUm47rCf5VQveZ6HDQIlzwUz599fh +iCYlZbe7yHCaOXJUk5TJdx94UJkg5mQWa1/wLM+edU6w5Y4bTPuVNTn06ylbyd6tFd/ msIA== 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 60-v6si2148882plc.444.2018.02.02.10.06.04; Fri, 02 Feb 2018 10:06:18 -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 S1753478AbeBBSDi (ORCPT + 99 others); Fri, 2 Feb 2018 13:03:38 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:37738 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753135AbeBBRI7 (ORCPT ); Fri, 2 Feb 2018 12:08:59 -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 401CDD31; Fri, 2 Feb 2018 17:08:58 +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 046/156] nvme-fabrics: introduce init command check for a queue that is not alive Date: Fri, 2 Feb 2018 17:57:07 +0100 Message-Id: <20180202140842.363281541@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 48832f8d58cfedb2f9bee11bbfbb657efb42e7e7 ] When the fabrics queue is not alive and fully functional, no commands should be allowed to pass but connect (which moves the queue to a fully functional state). Any other command should be failed, with either temporary status BLK_STS_RESOUCE or permanent status BLK_STS_IOERR. This is shared across all fabrics, hence move the check to fabrics library. Signed-off-by: Sagi Grimberg Signed-off-by: Christoph Hellwig Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/nvme/host/fabrics.h | 30 ++++++++++++++++++++++++++++++ drivers/nvme/host/rdma.c | 30 +++++------------------------- 2 files changed, 35 insertions(+), 25 deletions(-) --- a/drivers/nvme/host/fabrics.h +++ b/drivers/nvme/host/fabrics.h @@ -142,4 +142,34 @@ void nvmf_free_options(struct nvmf_ctrl_ int nvmf_get_address(struct nvme_ctrl *ctrl, char *buf, int size); bool nvmf_should_reconnect(struct nvme_ctrl *ctrl); +static inline blk_status_t nvmf_check_init_req(struct nvme_ctrl *ctrl, + struct request *rq) +{ + struct nvme_command *cmd = nvme_req(rq)->cmd; + + /* + * We cannot accept any other command until the connect command has + * completed, so only allow connect to pass. + */ + if (!blk_rq_is_passthrough(rq) || + cmd->common.opcode != nvme_fabrics_command || + cmd->fabrics.fctype != nvme_fabrics_type_connect) { + /* + * Reconnecting state means transport disruption, which can take + * a long time and even might fail permanently, fail fast to + * give upper layers a chance to failover. + * Deleting state means that the ctrl will never accept commands + * again, fail it permanently. + */ + if (ctrl->state == NVME_CTRL_RECONNECTING || + ctrl->state == NVME_CTRL_DELETING) { + nvme_req(rq)->status = NVME_SC_ABORT_REQ; + return BLK_STS_IOERR; + } + return BLK_STS_RESOURCE; /* try again later */ + } + + return BLK_STS_OK; +} + #endif /* _NVME_FABRICS_H */ --- a/drivers/nvme/host/rdma.c +++ b/drivers/nvme/host/rdma.c @@ -1603,31 +1603,11 @@ nvme_rdma_timeout(struct request *rq, bo * We cannot accept any other command until the Connect command has completed. */ static inline blk_status_t -nvme_rdma_queue_is_ready(struct nvme_rdma_queue *queue, struct request *rq) +nvme_rdma_is_ready(struct nvme_rdma_queue *queue, struct request *rq) { - if (unlikely(!test_bit(NVME_RDMA_Q_LIVE, &queue->flags))) { - struct nvme_command *cmd = nvme_req(rq)->cmd; - - if (!blk_rq_is_passthrough(rq) || - cmd->common.opcode != nvme_fabrics_command || - cmd->fabrics.fctype != nvme_fabrics_type_connect) { - /* - * reconnecting state means transport disruption, which - * can take a long time and even might fail permanently, - * fail fast to give upper layers a chance to failover. - * deleting state means that the ctrl will never accept - * commands again, fail it permanently. - */ - if (queue->ctrl->ctrl.state == NVME_CTRL_RECONNECTING || - queue->ctrl->ctrl.state == NVME_CTRL_DELETING) { - nvme_req(rq)->status = NVME_SC_ABORT_REQ; - return BLK_STS_IOERR; - } - return BLK_STS_RESOURCE; /* try again later */ - } - } - - return 0; + if (unlikely(!test_bit(NVME_RDMA_Q_LIVE, &queue->flags))) + return nvmf_check_init_req(&queue->ctrl->ctrl, rq); + return BLK_STS_OK; } static blk_status_t nvme_rdma_queue_rq(struct blk_mq_hw_ctx *hctx, @@ -1646,7 +1626,7 @@ static blk_status_t nvme_rdma_queue_rq(s WARN_ON_ONCE(rq->tag < 0); - ret = nvme_rdma_queue_is_ready(queue, rq); + ret = nvme_rdma_is_ready(queue, rq); if (unlikely(ret)) return ret;