From patchwork Mon Oct 5 15:26:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 268162 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95EE3C4363D for ; Mon, 5 Oct 2020 15:32:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 406CC208C7 for ; Mon, 5 Oct 2020 15:32:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601911970; bh=VwviBkeFQfpZQfvwJnmD7Z816gFKDnEJN6hT9796Wzc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=gfYYJilcp2SYn0+LJmwpi8oHkoO7JtLZU6VoiUTEpa6KWk9nqPOpa3fB1aUAlOOyt ReXNxqW7XzOKgg0KWVcRiXihHALKC15eufo2dpXqkt4ajUbcPMrAVa8S2UTZOFJT4U YyayUmKf0R5KLbq4PrdIFf63U+3rs6Lsae4EC0lg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728060AbgJEPcs (ORCPT ); Mon, 5 Oct 2020 11:32:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:60404 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728057AbgJEPco (ORCPT ); Mon, 5 Oct 2020 11:32:44 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3BE6F206DD; Mon, 5 Oct 2020 15:32:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601911962; bh=VwviBkeFQfpZQfvwJnmD7Z816gFKDnEJN6hT9796Wzc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NJluZKxntxiALPYeXx47SuRsLvziezabYBacgXITS2H6pa2ubDI0oJptFCU5u5iKM DhP9qQGFlxC6WKPgDqelixLk5gYa3d094fZNynSw0ItjVfp3aFm0m22wiMRw/8qgSF BhKHXeyaNN7WSm5q3nw2wBu2kn8JIS4OK1BhGXJk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, James Smart , Himanshu Madhani , Christoph Hellwig , Sasha Levin Subject: [PATCH 5.8 48/85] nvme-fc: fail new connections to a deleted host or remote port Date: Mon, 5 Oct 2020 17:26:44 +0200 Message-Id: <20201005142117.043082074@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201005142114.732094228@linuxfoundation.org> References: <20201005142114.732094228@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: James Smart [ Upstream commit 9e0e8dac985d4bd07d9e62922b9d189d3ca2fccf ] The lldd may have made calls to delete a remote port or local port and the delete is in progress when the cli then attempts to create a new controller. Currently, this proceeds without error although it can't be very successful. Fix this by validating that both the host port and remote port are present when a new controller is to be created. Signed-off-by: James Smart Reviewed-by: Himanshu Madhani Signed-off-by: Christoph Hellwig Signed-off-by: Sasha Levin --- drivers/nvme/host/fc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c index 92c966ac34c20..43c1745ecd45b 100644 --- a/drivers/nvme/host/fc.c +++ b/drivers/nvme/host/fc.c @@ -3668,12 +3668,14 @@ nvme_fc_create_ctrl(struct device *dev, struct nvmf_ctrl_options *opts) spin_lock_irqsave(&nvme_fc_lock, flags); list_for_each_entry(lport, &nvme_fc_lport_list, port_list) { if (lport->localport.node_name != laddr.nn || - lport->localport.port_name != laddr.pn) + lport->localport.port_name != laddr.pn || + lport->localport.port_state != FC_OBJSTATE_ONLINE) continue; list_for_each_entry(rport, &lport->endp_list, endp_list) { if (rport->remoteport.node_name != raddr.nn || - rport->remoteport.port_name != raddr.pn) + rport->remoteport.port_name != raddr.pn || + rport->remoteport.port_state != FC_OBJSTATE_ONLINE) continue; /* if fail to get reference fall through. Will error */