Received: by 10.223.176.46 with SMTP id f43csp282683wra; Tue, 23 Jan 2018 21:01:03 -0800 (PST) X-Google-Smtp-Source: AH8x224wivkBBAHvoBsDqHAq/xQiUG2l5qNQijroLFLz5b8qvqoQeoWNCIYUNFINZ7r+pbcdpbr+ X-Received: by 2002:a17:902:8a91:: with SMTP id p17-v6mr7068221plo.375.1516770062958; Tue, 23 Jan 2018 21:01:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516770062; cv=none; d=google.com; s=arc-20160816; b=pZ8X1EFeZ8CrmHl/QBx1IRgxVdwizmx3YttzCv/dMuz/AN/WQMAjRGRHaatNgHoLoe 8We1Ce/I4RUCrli5iiBrRfeC+5TX2OOe9GAQvSttrEU0+eK1AmEbNZiHnUBweuJtYgOQ jJ4LDT4Bc0bGmCsw+5wMQIVIp86EUWztg8GwnqSm/5zkikRMQf4bC8wssy+Ey0CFvpuQ ZeWv/RPWdYyn6ht1WZ8CXtpsHbMSe+7ay9Twu66VSL3XEo2RWZ9fqk+7xuQU9pAPUq2K 8HRShZOXG69XVh5DS1cAl5oEZ1wegi86aVd5gtGcBlIPgAC5rQIdOIoTD9oPTUoddjn5 gysA== 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=wkcJ+B595eraQ/3qi0GeLozijc10A+eVGimcMQvlNlM=; b=YP1u9RPp5O0/5Sz9VquCA0RWQfwP4v/+BGSG7sKMZ3U0/Siu5X6rXSWXyrbvSZSScA QuxkvklrAj6mfIVusM3XbMbG/qMB+/2mn6CYuhm4SZ//s+gUzJX8F1P6eesSFuZcLlR5 C6RSYu1mbK/6KPj4mHgJKdCaKMGq48x4Px7QYcSxN7YpowjEg6S5+ENKMFQzpKkTFTWq 9q7By2Q3cyyDJRjktIssHNRR/IVrWG/oSSw1JgYU/OTvtx0tdcGKygi15kBsUJ7OwnY3 ctDYPp+EXqAL+IAZhtkVj+Mt/kYUg+T+lPY3esf+4CelMkcoH+scATSignnKKAAGf+6r YTLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=RMKUwdOj; 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 n19si15474692pgf.422.2018.01.23.21.00.49; Tue, 23 Jan 2018 21:01:02 -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=RMKUwdOj; 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 S932141AbeAXEPO (ORCPT + 99 others); Tue, 23 Jan 2018 23:15:14 -0500 Received: from mail-cys01nam02on0090.outbound.protection.outlook.com ([104.47.37.90]:39872 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752749AbeAXEOj (ORCPT ); Tue, 23 Jan 2018 23:14:39 -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=wkcJ+B595eraQ/3qi0GeLozijc10A+eVGimcMQvlNlM=; b=RMKUwdOjmg+HIy4ewV3gBteirZmg3iHSNQNNsdx5mrpesbysPYN2LdMAZYdJKt2lTUCKv58bvCV2Gp5x143ZCNHwiuzufzmBHBlYQb7VS4caIuYEdCfcsqFNtxFppQUAHP1/tCHLa3h+v71lhZiM4Br6zAsbpef6MoPWUwhddXg= 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:33 +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:33 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: James Smart , James Smart , Christoph Hellwig , Sasha Levin Subject: [PATCH AUTOSEL for 4.14 022/100] nvmet-fc: correct ref counting error when deferred rcv used Thread-Topic: [PATCH AUTOSEL for 4.14 022/100] nvmet-fc: correct ref counting error when deferred rcv used Thread-Index: AQHTlMnWIGJCbLDT/0KPWvTUku6iGQ== Date: Wed, 24 Jan 2018 04:14:33 +0000 Message-ID: <20180124041414.32065-22-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:FO9VOz75C2RjbRX2NOqmZzT3D7PQh0YLb2POZTX0Q5gRAeOJb9tPVVuNDMNCpObjkT4ajuLWL7MqUI4Cv9a0VzSeQEcJcY8GDoPWmcTvTnQ13azSh/ESaT/QAm40MKknmtAMlFV0NlD52+Ec5BkXDC354aYCyA94BFxq1KngGhP3V18VVptRDGjXN8rEs5Oby4Gr/tNPRsg/vPSnqi+UrIUYvqUDQZhDl0F9SVP292zwZ03RG3UugzVKrPEGz23T x-ms-exchange-antispam-srfa-diagnostics: SSOS;SSOR; x-ms-office365-filtering-correlation-id: 53a3fc7f-54f4-41f1-0483-08d562e0f963 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)(85827821059158); 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)(39060400002)(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: Ztg33q44IHUAKV82aXkvQ5KV6tnwCXKCRhDO0DYnR+sgDKg4Yx30umq0NQ6XvqfAVXSFwBc2Aq4NynqbhHb2Gw== 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: 53a3fc7f-54f4-41f1-0483-08d562e0f963 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Jan 2018 04:14:33.7334 (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: James Smart [ Upstream commit 619c62dcc62b957d17cccde2081cad527b020883 ] Whenever a cmd is received a reference is taken while looking up the queue. The reference is removed after the cmd is done as the iod is returned for reuse. The fod may be reused for a deferred (recevied but no job context) cmd. Existing code removes the reference only if the fod is not reused for another command. Given the fod may be used for one or more ios, although a reference was taken per io, it won't be matched on the frees. Remove the reference on every fod free. This pairs the references to each io. Signed-off-by: James Smart Reviewed-by: Sagi Grimberg Signed-off-by: Christoph Hellwig Signed-off-by: Sasha Levin --- drivers/nvme/target/fc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c index 58e010bdda3e..8e21211b904b 100644 --- a/drivers/nvme/target/fc.c +++ b/drivers/nvme/target/fc.c @@ -532,15 +532,15 @@ nvmet_fc_free_fcp_iod(struct nvmet_fc_tgt_queue *queu= e, =20 tgtport->ops->fcp_req_release(&tgtport->fc_target_port, fcpreq); =20 + /* release the queue lookup reference on the completed IO */ + nvmet_fc_tgt_q_put(queue); + spin_lock_irqsave(&queue->qlock, flags); deferfcp =3D list_first_entry_or_null(&queue->pending_cmd_list, struct nvmet_fc_defer_fcp_req, req_list); if (!deferfcp) { list_add_tail(&fod->fcp_list, &fod->queue->fod_list); spin_unlock_irqrestore(&queue->qlock, flags); - - /* Release reference taken at queue lookup and fod allocation */ - nvmet_fc_tgt_q_put(queue); return; } =20 @@ -759,6 +759,9 @@ nvmet_fc_delete_target_queue(struct nvmet_fc_tgt_queue = *queue) tgtport->ops->fcp_req_release(&tgtport->fc_target_port, deferfcp->fcp_req); =20 + /* release the queue lookup reference */ + nvmet_fc_tgt_q_put(queue); + kfree(deferfcp); =20 spin_lock_irqsave(&queue->qlock, flags); --=20 2.11.0