Received: by 10.223.176.46 with SMTP id f43csp286282wra; Tue, 23 Jan 2018 21:05:26 -0800 (PST) X-Google-Smtp-Source: AH8x226uRJ4fOzw6g2kzai+phJPHOGSC6musoHa0NYSuwPCd3YFw5QrZUs4bIHJcwvRsE5J0PdH5 X-Received: by 2002:a17:902:9346:: with SMTP id g6-v6mr7143667plp.379.1516770326704; Tue, 23 Jan 2018 21:05:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516770326; cv=none; d=google.com; s=arc-20160816; b=hRYZyB76AL1rloCLYu0d7ypTnN3WoMcq3ltu87Xv/gzjU+oaB/axCb/+bzVkHMO9V5 sNh8fIzD4Q1YHZ8+mCgjMcHMAAOlbn+zP5YhNEgA4CpmES4IfmVzPtofLpc6op/JT3Gr S0ufPray2+FMVEMBqMM4HJeYhfyc4412wYLEn/HJKKjoyNuGlTbAUxwGBPEi3RikmZES 3ofMpT37bTAa+rVzz/dt8VfGtbNhGGZUqlNJ1EMfkWD4F0dVdjR5u1J/lmnj+os3QV3U 7wSmrVoqpUSeDo6Z90rxseb+leeWFmmWG8r864T7Zvg1QAIpkPHHcPK8875M7pyrroLo Sutw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=zLEnES22vxEx2sTwKKs/8t/994GQ23R9G0aiv0Bera8=; b=XT67DkGxzSGdIchVcy605SOL2A004uZEa0VnDiNJF0SzFLA5lQhXOec0WxYSbyLpBV On+e52n0afkiROebmPsc1c3nIjRM0637MlswGD4oCVBy444rcYSQcYWAmrYIZBpcpo4J 2Ivsz4PMzNmvgbaaC4G4otQdq+RnVz7IDKgMppvTGiTTSKSfuXAvXWaH6Un3wt4KRbxu vy3Fe567QFVQUbsujN7s1Zrgl152h1DmKi7lX3+gOCn9SorTKKtN7iTSTg2/J3wZQau3 EEQ+8MIHb1AI42Mb9T5kyJXMysrJHfpZw18pVM7W1zsMQEZDHsxYaNutFRJmy2WOM8xh hzGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=hOi/OXzA; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i90-v6si3879526pli.676.2018.01.23.21.05.13; Tue, 23 Jan 2018 21:05: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; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=hOi/OXzA; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932092AbeAXFDk (ORCPT + 99 others); Wed, 24 Jan 2018 00:03:40 -0500 Received: from mail-cys01nam02on0130.outbound.protection.outlook.com ([104.47.37.130]:40075 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752667AbeAXEOf (ORCPT ); Tue, 23 Jan 2018 23:14:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=zLEnES22vxEx2sTwKKs/8t/994GQ23R9G0aiv0Bera8=; b=hOi/OXzAyCCVrddrfoyKVB6hyuyXIZPw1fiVW0EthBhZL2W41AgXXElXwIsjrsdmxIYE/Awed1K8jaK4eil5KSeWzy9DZrY9IKDUt0sl/TrMDk55oGpDIFndoNA3Ty2OZ6trqXyjH1BFN13709Q2qj5dp+/9AR4mSD5lb69oz24= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0920.namprd21.prod.outlook.com (52.132.132.165) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.464.3; Wed, 24 Jan 2018 04:14:30 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::6485:b98:d15e:9da7]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::6485:b98:d15e:9da7%2]) with mapi id 15.20.0464.000; Wed, 24 Jan 2018 04:14:30 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Sagi Grimberg , Christoph Hellwig , "Sasha Levin" Subject: [PATCH AUTOSEL for 4.14 017/100] nvme-fabrics: introduce init command check for a queue that is not alive Thread-Topic: [PATCH AUTOSEL for 4.14 017/100] nvme-fabrics: introduce init command check for a queue that is not alive Thread-Index: AQHTlMnVS9HLKrbFpECWv6SKuOVwRA== Date: Wed, 24 Jan 2018 04:14:30 +0000 Message-ID: <20180124041414.32065-17-alexander.levin@microsoft.com> References: <20180124041414.32065-1-alexander.levin@microsoft.com> In-Reply-To: <20180124041414.32065-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB0920;7:Ece3h8ZMOQOHm+xUckPwQwEtxWiZYNeL/qM0TEYOb+fhQayzf4OizN7Mpa0/aUszqng2+wI1YtR5FEPrUsLMsed310va1+UJaCw1SN+CpPOTqYXz3hsw9d7fAArfWAyDAvHhuYTRMcJyZ8ZazXOIC1+PjmEw/D84MM929IUb+X1L1KjHzVszN5Ccq0wKJ9pjVQX+qg/LGEvbQDhaNxdw75UohyyBfyd62XQbhOTPw58FA81Mq1FH9mRcEk59S9F/ x-ms-exchange-antispam-srfa-diagnostics: SSOS;SSOR; x-ms-office365-filtering-correlation-id: f2b89597-0483-4850-0d3d-08d562e0f79d x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(2017052603307)(7193020);SRVR:DM5PR2101MB0920; x-ms-traffictypediagnostic: DM5PR2101MB0920: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(21532816269658); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(61425038)(6040501)(2401047)(8121501046)(5005006)(3231046)(2400081)(944501161)(93006095)(93001095)(3002001)(10201501046)(6055026)(61426038)(61427038)(6041288)(20161123558120)(20161123564045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(6072148)(201708071742011);SRVR:DM5PR2101MB0920;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0920; x-forefront-prvs: 056297E276 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39860400002)(366004)(376002)(396003)(39380400002)(346002)(189003)(199004)(105586002)(106356001)(86362001)(2900100001)(66066001)(305945005)(14454004)(22452003)(72206003)(3280700002)(3660700001)(10290500003)(5660300001)(36756003)(2950100002)(7736002)(478600001)(110136005)(316002)(97736004)(81166006)(6116002)(3846002)(26005)(1076002)(6346003)(54906003)(25786009)(81156014)(6436002)(10090500001)(68736007)(107886003)(99286004)(8676002)(8936002)(4326008)(5250100002)(2501003)(86612001)(6486002)(59450400001)(2906002)(6506007)(76176011)(6512007)(102836004)(53936002)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0920;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-message-info: 1XjCOwmHpLqTGRP4gWGN3cCB8d9IJW14bS4zIpcLoYoL6dOzWogb/2Bv5Q6x6//Rxi1cZNLsMlSCEV754dtCHQ== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: f2b89597-0483-4850-0d3d-08d562e0f79d X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Jan 2018 04:14:30.7723 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0920 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/nvme/host/fabrics.h | 30 ++++++++++++++++++++++++++++++ drivers/nvme/host/rdma.c | 32 ++++++-------------------------- 2 files changed, 36 insertions(+), 26 deletions(-) diff --git a/drivers/nvme/host/fabrics.h b/drivers/nvme/host/fabrics.h index bf33663218cd..9ff8529a64a9 100644 --- a/drivers/nvme/host/fabrics.h +++ b/drivers/nvme/host/fabrics.h @@ -142,4 +142,34 @@ void nvmf_free_options(struct nvmf_ctrl_options *opts)= ; int nvmf_get_address(struct nvme_ctrl *ctrl, char *buf, int size); bool nvmf_should_reconnect(struct nvme_ctrl *ctrl); =20 +static inline blk_status_t nvmf_check_init_req(struct nvme_ctrl *ctrl, + struct request *rq) +{ + struct nvme_command *cmd =3D 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 !=3D nvme_fabrics_command || + cmd->fabrics.fctype !=3D 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 =3D=3D NVME_CTRL_RECONNECTING || + ctrl->state =3D=3D NVME_CTRL_DELETING) { + nvme_req(rq)->status =3D NVME_SC_ABORT_REQ; + return BLK_STS_IOERR; + } + return BLK_STS_RESOURCE; /* try again later */ + } + + return BLK_STS_OK; +} + #endif /* _NVME_FABRICS_H */ diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c index 0ebb539f3bd3..6de163e6c9eb 100644 --- a/drivers/nvme/host/rdma.c +++ b/drivers/nvme/host/rdma.c @@ -1603,31 +1603,11 @@ nvme_rdma_timeout(struct request *rq, bool reserved= ) * We cannot accept any other command until the Connect command has comple= ted. */ static inline blk_status_t -nvme_rdma_queue_is_ready(struct nvme_rdma_queue *queue, struct request *rq= ) -{ - if (unlikely(!test_bit(NVME_RDMA_Q_LIVE, &queue->flags))) { - struct nvme_command *cmd =3D nvme_req(rq)->cmd; - - if (!blk_rq_is_passthrough(rq) || - cmd->common.opcode !=3D nvme_fabrics_command || - cmd->fabrics.fctype !=3D 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 =3D=3D NVME_CTRL_RECONNECTING || - queue->ctrl->ctrl.state =3D=3D NVME_CTRL_DELETING) { - nvme_req(rq)->status =3D NVME_SC_ABORT_REQ; - return BLK_STS_IOERR; - } - return BLK_STS_RESOURCE; /* try again later */ - } - } - - return 0; +nvme_rdma_is_ready(struct nvme_rdma_queue *queue, struct request *rq) +{ + if (unlikely(!test_bit(NVME_RDMA_Q_LIVE, &queue->flags))) + return nvmf_check_init_req(&queue->ctrl->ctrl, rq); + return BLK_STS_OK; } =20 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(struct blk_mq_= hw_ctx *hctx, =20 WARN_ON_ONCE(rq->tag < 0); =20 - ret =3D nvme_rdma_queue_is_ready(queue, rq); + ret =3D nvme_rdma_is_ready(queue, rq); if (unlikely(ret)) return ret; =20 --=20 2.11.0