Received: by 10.223.176.46 with SMTP id f43csp285271wra; Tue, 23 Jan 2018 21:04:11 -0800 (PST) X-Google-Smtp-Source: AH8x225yUPzpGNzGgPixZSeMW3nGWhx9bNxmvl3We8eiTkm7CAV0HbXhdIrn3vFpKa8Yq2kDWzat X-Received: by 2002:a17:902:bd8e:: with SMTP id q14-v6mr2008517pls.123.1516770251068; Tue, 23 Jan 2018 21:04:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516770251; cv=none; d=google.com; s=arc-20160816; b=1HP5ncmtUnCvEb8uOBAAY2ejx3H6Gkf86UI/zhjQFY+glw9bw0yTx8tORiTdmKMATR hYYZfSJreVziyAM0YFIQ/TmqaEiZgsBMAnaOQSK//PRM8Z9tHiPUfOyjrBK8RrZ1FkmY P90dQMbye/jTqTxciVZIaGrHF8G4cKQMViHe8q48S6XdcprYELzpjbOV2/llfEB5aZa/ 0sH4b5h8uIaOgNWyVHdcDSeZwZf6qCYfYim4dPfPeKfeaw/dZ/yOmCYa+Xww6ipUc3FI 1sNmInXKbnE7mdnyJNvkLPucMA0mjb6uXb/6swOujB7VhyYKOqvpAkaVCWzeBZBY6T83 QZmQ== 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=qla/NCVcVHJ9eT7hW4aKJrYkRU3RBK5jCwn/cQ8Io9E=; b=l1rGDQ+9xAke8k/ihZJshIrkVTQA9Q0Qmho8JsUnR/uqpQvi97TFVQKch0BsTe5N1p JvWvGfh4VgbnL6gGf+NPlPA0EZQXlV+bJ8GofrFbDibxOtIv3koRjZgrGeKIbA7NsItu fBMQHj1LTM0f05EkNXMumKIQHtAOiVjS/Dsvg6PuLm0KU3ZbDoP1Onn5Wk5cgKQQAO8e yqZMVjFPQFGB7pfwYRJXcFtGTkvM9Tmnyqmq0HV63CTW3CzY177dVGZUnsS8w8GkZATo SPSRe0V2HRQIjdH1NmH6BW9nTvKfveqkct+MiieHUhPyxy07ynPNdzslJN9YCqVWGOS3 /Hkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=BNRWceD8; 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 q127si8376254pga.660.2018.01.23.21.03.57; Tue, 23 Jan 2018 21:04:11 -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=BNRWceD8; 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 S1752166AbeAXFDH (ORCPT + 99 others); Wed, 24 Jan 2018 00:03:07 -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 S1752578AbeAXEOg (ORCPT ); Tue, 23 Jan 2018 23:14:36 -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=qla/NCVcVHJ9eT7hW4aKJrYkRU3RBK5jCwn/cQ8Io9E=; b=BNRWceD8xPI4GdE4qz90FKg2AMYrGU9si/RFLBpn3wBiFzyc/mOcux6qq20ehL0+E1dsty/b5GNiiKFL7iVFziXdChjE4/EGz5o9SOE/Eobn8+2w+6JbswCi8UdxJsS2ge/KH6Wpm18PMaAA1Q/rfmFfhH9/gUoj3k8OARnGmjs= 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:31 +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:31 +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 018/100] nvme-fc: check if queue is ready in queue_rq Thread-Topic: [PATCH AUTOSEL for 4.14 018/100] nvme-fc: check if queue is ready in queue_rq Thread-Index: AQHTlMnV2PMFKytYxU24jD68cQzk0A== Date: Wed, 24 Jan 2018 04:14:31 +0000 Message-ID: <20180124041414.32065-18-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;6:loUS8we8ZSqPRvanbAjD1I0yYfEvF3HqdyBrfHQ18uv8JWgZxS9fzVvyq/+gmYvfErO/ps7jjo+Ca0oVw38Jcr+GHxOlEhqUpZJuZT+v2eozw+XEHFgS8m13wZTJr6rxiL3Y85iyykcRJukL5eXXYzB/gDCZL6uKKKElQsmsnf8CaqK1y1VfHGU6I/Ry1Vl8ak941YEuTnnGO5ZuMt1lVBd2alJfC/03nti4xwtwXFTRZNWSHXL6ItN8njFZ84diJkQi6BrnlwHngdPogog2wXNEinj8UghLAXfKvpcRGIHcCuH7d3tl4UKGA6BnZdE55GvpCK2o98qWBREp3WShp0WCoN1lAYWlNOA8XKkifuEUi+NJwfu4ZmD5jltMMCuU;5:WKgiyhFgCQ3UY+l7y9wgPz41emVuh1MNU4hhy6T+82nBzI3u3it5P1H4sX6fze3goCBjJpmGX8XPTYY/chwTQnVRjOSu6MYSbr1JXIaNSRYriDeZjFqJrEDYwETK/iRWqH4iLtRf98u3wv7/5sElpOh0MQLJqQo+kWTn6FrjMNM=;24:PjrKLCduEEb6RecbfWuwYvCI/MaRdoOfBYJWC48ZFHFd4HXz5LULT2sNLBf2k7jXIhfwVmo8FddtWp43ry0LWaPUhecc/Ne7Gqmkd1untqY=;7:bnQBn3oiadtqH8eY6JjefdbQCqgvB91oGw8LhU5cR2moaZXr3a76t/O8rkXCQh3Lf9emqSRsZrC7Br9LSdFpUez+eHvyfSmmFkPXWY0eypecsbzHFZuZ9ATkFxiuvJD4C/gA7rrqk+0JPNVsBMRaJU9AQy0PcR9EI9bCoxnv+I9a6be5p4R8g05lA9ZitsnfOdnwlj57I4uSuqeqrWYYlZIECjjx3aOm4ZiPTMiphyDD/j02w8Eku15sKqqLkKm7 x-ms-exchange-antispam-srfa-diagnostics: SSOS;SSOR; x-ms-office365-filtering-correlation-id: 6137851d-d7b6-4677-8822-08d562e0f7f6 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)(979002)(39860400002)(366004)(376002)(396003)(39380400002)(346002)(189003)(199004)(105586002)(106356001)(86362001)(2900100001)(66066001)(305945005)(14454004)(22452003)(72206003)(3280700002)(3660700001)(10290500003)(5660300001)(36756003)(2950100002)(575784001)(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)(969003)(989001)(999001)(1009001)(1019001);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: Y05ZTNEIKny52XoLcayHcqU/DqBPNJ8mx0D/CpHPQ1ORjFhhdbMDDFkpZBsIGfHl7Qfg4t2Q4uOUvLmi948shw== 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: 6137851d-d7b6-4677-8822-08d562e0f7f6 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Jan 2018 04:14:31.3547 (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 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 --- drivers/nvme/host/fc.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c index be49d0f79381..3148d760d825 100644 --- a/drivers/nvme/host/fc.c +++ b/drivers/nvme/host/fc.c @@ -41,6 +41,7 @@ =20 enum nvme_fc_queue_flags { NVME_FC_Q_CONNECTED =3D (1 << 0), + NVME_FC_Q_LIVE =3D (1 << 1), }; =20 #define NVMEFC_QUEUE_DELAY 3 /* ms units */ @@ -1654,6 +1655,7 @@ nvme_fc_free_queue(struct nvme_fc_queue *queue) if (!test_and_clear_bit(NVME_FC_Q_CONNECTED, &queue->flags)) return; =20 + 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) */ =20 queue->connection_id =3D 0; - clear_bit(NVME_FC_Q_CONNECTED, &queue->flags); } =20 static void @@ -1740,6 +1741,8 @@ nvme_fc_connect_io_queues(struct nvme_fc_ctrl *ctrl, = u16 qsize) ret =3D nvmf_connect_io_queue(&ctrl->ctrl, i); if (ret) break; + + set_bit(NVME_FC_Q_LIVE, &ctrl->queues[i].flags); } =20 return ret; @@ -2048,6 +2051,14 @@ busy: return BLK_STS_RESOURCE; } =20 +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 *hctx, u32 data_len; blk_status_t ret; =20 + ret =3D nvme_fc_is_ready(queue, rq); + if (unlikely(ret)) + return ret; + ret =3D nvme_setup_cmd(ns, rq, sqe); if (ret) return ret; @@ -2398,6 +2413,8 @@ nvme_fc_create_association(struct nvme_fc_ctrl *ctrl) if (ret) goto out_disconnect_admin_queue; =20 + set_bit(NVME_FC_Q_LIVE, &ctrl->queues[0].flags); + /* * Check controller capabilities * --=20 2.11.0