Received: by 10.223.176.46 with SMTP id f43csp284470wra; Tue, 23 Jan 2018 21:03:12 -0800 (PST) X-Google-Smtp-Source: AH8x227/+W/8ophpPAhzXo7MZA36H7V/eM1OVqyWh0Fq/I9t2TEJt7aD+lsEnSv7Oi1PifXpGrEk X-Received: by 10.99.126.26 with SMTP id z26mr9815994pgc.151.1516770192659; Tue, 23 Jan 2018 21:03:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516770192; cv=none; d=google.com; s=arc-20160816; b=KW162uFzWDgC6fAwaGf6e7QAPf/75maHWYFvZYJV7AjcTnKDfG8iRgH45HNZ7HXfdq bNqNKa/bDtqcasULOtpaShJaUVQFfIRQMhRPYdy0WD3K74uO1P+I/ihDN4WWaXNHiDPK NF2R8SroZ1cNu7kQeN1tTyrhN/CGR744xbzZkqlblLD9kwc4Y1eItDZaGh7fo6jWon4a OVlRlLIr38RPQQ3UfkDcrq7PcerHpxQOYg6s2AamoyU9VOeIEpJBKi79CbsYXMwCNqXy XzYcU63EFW0V0JBDzursm9yJmZZuZtaXGuSCetNp2FhV8viq4xGZ+4b4P6PKDkBtSnwB HFBw== 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=tU/y4v88LXoy6d/vEDxUGFBNU3z5hXK0CdIvaSIxx2k=; b=sXnVJeiKjj7ak9dYfVUmdQyCmkR6KoTuSs9o1KslkoFc71XxEVZZyZeyMzWrHCEAiL VI1jcWbHUnrU5mnInQLr3tFWbCXIE6ICJVtzyTTWUDpM5E/7v+NECcbzcatZdR8MLDrr f5ULTvPv6IYSq2nxUXHwCZmVGw2IBFfYzKvNmlvBMS3xNXoj0m+j+cMinHYgmQt23EK+ R9opP0X2NRydD1FeCcF08UEyfe0AtjImbZQ6CvMSmrLb3YErdrDkQmSMjsuWPLutI58n 6CQ+9yD+Z4Qh+bNqsOnPvI7iOpn1hcZYkEe+3N6RbahtFSm5sBHCpJCpsXicm4CSNOAf TPaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=g7R0Szqu; 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 y6si15661365pgc.112.2018.01.23.21.02.58; Tue, 23 Jan 2018 21:03:12 -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=g7R0Szqu; 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 S1752795AbeAXFCf (ORCPT + 99 others); Wed, 24 Jan 2018 00:02:35 -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 S1752700AbeAXEOh (ORCPT ); Tue, 23 Jan 2018 23:14:37 -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=tU/y4v88LXoy6d/vEDxUGFBNU3z5hXK0CdIvaSIxx2k=; b=g7R0Szqu6DWapeOQCAzdPMmHIYl6LRHj8TSkodjdRz2g3JjPka9JXXsmS78oy+y13npStqySi4vyV8WHuEaaSmiRnFG5pSXcvpsWxC/W9TxV/SNNtOGeT3UoW4kJ0vFov6hzR0iR9ML48PP512J2OWC5I22jrxxXjV8S2isc5E4= 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:32 +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:32 +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 019/100] nvme-loop: check if queue is ready in queue_rq Thread-Topic: [PATCH AUTOSEL for 4.14 019/100] nvme-loop: check if queue is ready in queue_rq Thread-Index: AQHTlMnVDqJbR8j2E0WBQJvnLHL/IA== Date: Wed, 24 Jan 2018 04:14:31 +0000 Message-ID: <20180124041414.32065-19-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:5aTtEKdWtjcSSQ8Vsq4whnzSW49yu+l4iRkm6c7mby7n+SpfGd/Fv45TTBXv2k4Fna8jGm/QUWaRvxtA3O9TPdLfMcCiXGBqetbJxeW1eJNd+ixMUIfgWYnqfWnxz7KqB02QmsODFgG+CcweMXo4/YwmrxjkIs9t7eEcCXiddfrZ5kK1thyAHnl04DwH3JSxTeyaOjCyCuUMQrhdYBtVj4xo7vfZuhNDQunE5VuAyTvJhkpYUcQUM3N64jTM/KLS x-ms-exchange-antispam-srfa-diagnostics: SSOS;SSOR; x-ms-office365-filtering-correlation-id: 5017d57f-237a-48c0-c4f3-08d562e0f85b 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)(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: WjmogWvTY91h41RMu3X4JkNmrsNH6LicHb//jno64qXkyx5ZgdEOs/Ieosplv+vnOmp87AKSCtn7hmfe0NYy5w== 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: 5017d57f-237a-48c0-c4f3-08d562e0f85b X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Jan 2018 04:14:32.0102 (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 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 --- drivers/nvme/target/loop.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/target/loop.c b/drivers/nvme/target/loop.c index 92628c432926..02aff5cc48bf 100644 --- a/drivers/nvme/target/loop.c +++ b/drivers/nvme/target/loop.c @@ -61,10 +61,15 @@ static inline struct nvme_loop_ctrl *to_loop_ctrl(struc= t nvme_ctrl *ctrl) return container_of(ctrl, struct nvme_loop_ctrl, ctrl); } =20 +enum nvme_loop_queue_flags { + NVME_LOOP_Q_LIVE =3D 0, +}; + struct nvme_loop_queue { struct nvmet_cq nvme_cq; struct nvmet_sq nvme_sq; struct nvme_loop_ctrl *ctrl; + unsigned long flags; }; =20 static struct nvmet_port *nvmet_loop_port; @@ -153,6 +158,14 @@ nvme_loop_timeout(struct request *rq, bool reserved) return BLK_EH_HANDLED; } =20 +static inline blk_status_t nvme_loop_is_ready(struct nvme_loop_queue *queu= e, + 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(struct blk_mq_h= w_ctx *hctx, struct nvme_loop_iod *iod =3D blk_mq_rq_to_pdu(req); blk_status_t ret; =20 + ret =3D nvme_loop_is_ready(queue, req); + if (unlikely(ret)) + return ret; + ret =3D nvme_setup_cmd(ns, req, &iod->cmd); if (ret) return ret; @@ -275,6 +292,7 @@ static const struct blk_mq_ops nvme_loop_admin_mq_ops = =3D { =20 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(struct nvme_lo= op_ctrl *ctrl) { int i; =20 - for (i =3D 1; i < ctrl->ctrl.queue_count; i++) + for (i =3D 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); + } } =20 static int nvme_loop_init_io_queues(struct nvme_loop_ctrl *ctrl) @@ -346,6 +366,7 @@ static int nvme_loop_connect_io_queues(struct nvme_loop= _ctrl *ctrl) ret =3D nvmf_connect_io_queue(&ctrl->ctrl, i); if (ret) return ret; + set_bit(NVME_LOOP_Q_LIVE, &ctrl->queues[i].flags); } =20 return 0; @@ -387,6 +408,8 @@ static int nvme_loop_configure_admin_queue(struct nvme_= loop_ctrl *ctrl) if (error) goto out_cleanup_queue; =20 + set_bit(NVME_LOOP_Q_LIVE, &ctrl->queues[0].flags); + error =3D nvmf_reg_read64(&ctrl->ctrl, NVME_REG_CAP, &ctrl->ctrl.cap); if (error) { dev_err(ctrl->ctrl.device, --=20 2.11.0