Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp869234pxb; Tue, 1 Feb 2022 12:06:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJzeFGnB2DlYsS4x2qmL5GfgqWbsE+v1+uy4DBJdjfK1dzFYUL/aGBwcSoLAI6who1IAEbeg X-Received: by 2002:a17:907:2511:: with SMTP id y17mr22508051ejl.353.1643745982398; Tue, 01 Feb 2022 12:06:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643745982; cv=none; d=google.com; s=arc-20160816; b=f3BCxn2mKaHEl4y6KhqSsLXQnGLwLCEyvKxKzqMWlFApxLM954isHkdQB3XFaM1npM wtUmpziWQ8zst+rlQC/ujP5ZbFyyeERevoSXrk4OzyFzFQQ4eryL0bePXQtos3LU3YUR 6/pgCQijYZsL1eedBVGs3u04E7o4b/nnU1vssuzkw9+qIF7ofjzj2jtYnjrIOm7n0yGx wN+G1nJbbSEnWMaNc+XRI41nRf+bPLjKDz2SCxhtp+kfarDfbcCpu+rWjRHjGHMglP7S vAE+K8pH/pNJoKwEfMDkfKyMrspHkdP7bw1ItdchCCik1oHR6C0YHu8FiQTdyEXqYM0H Vy+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=3y43rlO1dMz8HGFfZZQYXxKzXmUPZWw16uhgPApNxJc=; b=LrXN1sAUyOxGTKtIt5J0mzfDV91lkjvaayQatsX7A0BZ8a524iPaMtLz62rkKhMY+g 5M/DaeM1BqvswnwMGUYLmsFQUD+HbgGz6RYlen9C2qLiAKVETK4D6VbZtv2x6NX7H8KC XccbArvePeDyMYTy4Yp2Ar7qx1wvmL+vdvY2Br2V9dzHf7YgJTE+6yJjz/unHzCAPiio LuoljKxtbh1sAuqu5q5JtwBAse8qNpwQb+YD2pe03ltidQfl82ghxSilbTv1zEkIFZ5O lcU83w+QfZCuthH/QLNX9ljyoyq1JAXnEk1rxnIFGDhxFp8OUPwnK85ZxIFIOQkrscmq yZ5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=s0cKi+QF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u8si9873136eds.8.2022.02.01.12.05.54; Tue, 01 Feb 2022 12:06:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=s0cKi+QF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349892AbiAaLRT (ORCPT + 99 others); Mon, 31 Jan 2022 06:17:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377300AbiAaLJy (ORCPT ); Mon, 31 Jan 2022 06:09:54 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B96F8C0613BB; Mon, 31 Jan 2022 03:07:10 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 56C3760FE1; Mon, 31 Jan 2022 11:07:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2C549C340EE; Mon, 31 Jan 2022 11:07:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643627229; bh=73BdNz4Hg5qLRQTfuS4+6Pt09s5QMlox2v1WqQLxkag=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s0cKi+QFrGPJYedwybWWhJIx/qKuQmczx5vTA+4sGiEeg08kKc5Ug24y5nCcIvNoC ADVzGpMgeIyG+jqJ7qw/T5jF5kBNRkxScCYfb3CbGLHEc2h6TAwmAVDSdhf2HcLBKF HIcOTSucz6rZjq+CDdsXkcvUOTdZBGii78QsB7Ro= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Benjamin Block , Steffen Maier , "Martin K. Petersen" Subject: [PATCH 5.15 016/171] scsi: zfcp: Fix failed recovery on gone remote port with non-NPIV FCP devices Date: Mon, 31 Jan 2022 11:54:41 +0100 Message-Id: <20220131105230.564333951@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220131105229.959216821@linuxfoundation.org> References: <20220131105229.959216821@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Steffen Maier commit 8c9db6679be4348b8aae108e11d4be2f83976e30 upstream. Suppose we have an environment with a number of non-NPIV FCP devices (virtual HBAs / FCP devices / zfcp "adapter"s) sharing the same physical FCP channel (HBA port) and its I_T nexus. Plus a number of storage target ports zoned to such shared channel. Now one target port logs out of the fabric causing an RSCN. Zfcp reacts with an ADISC ELS and subsequent port recovery depending on the ADISC result. This happens on all such FCP devices (in different Linux images) concurrently as they all receive a copy of this RSCN. In the following we look at one of those FCP devices. Requests other than FSF_QTCB_FCP_CMND can be slow until they get a response. Depending on which requests are affected by slow responses, there are different recovery outcomes. Here we want to fix failed recoveries on port or adapter level by avoiding recovery requests that can be slow. We need the cached N_Port_ID for the remote port "link" test with ADISC. Just before sending the ADISC, we now intentionally forget the old cached N_Port_ID. The idea is that on receiving an RSCN for a port, we have to assume that any cached information about this port is stale. This forces a fresh new GID_PN [FC-GS] nameserver lookup on any subsequent recovery for the same port. Since we typically can still communicate with the nameserver efficiently, we now reach steady state quicker: Either the nameserver still does not know about the port so we stop recovery, or the nameserver already knows the port potentially with a new N_Port_ID and we can successfully and quickly perform open port recovery. For the one case, where ADISC returns successfully, we re-initialize port->d_id because that case does not involve any port recovery. This also solves a problem if the storage WWPN quickly logs into the fabric again but with a different N_Port_ID. Such as on virtual WWPN takeover during target NPIV failover. [https://www.redbooks.ibm.com/abstracts/redp5477.html] In that case the RSCN from the storage FDISC was ignored by zfcp and we could not successfully recover the failover. On some later failback on the storage, we could have been lucky if the virtual WWPN got the same old N_Port_ID from the SAN switch as we still had cached. Then the related RSCN triggered a successful port reopen recovery. However, there is no guarantee to get the same N_Port_ID on NPIV FDISC. Even though NPIV-enabled FCP devices are not affected by this problem, this code change optimizes recovery time for gone remote ports as a side effect. The timely drop of cached N_Port_IDs prevents unnecessary slow open port attempts. While the problem might have been in code before v2.6.32 commit 799b76d09aee ("[SCSI] zfcp: Decouple gid_pn requests from erp") this fix depends on the gid_pn_work introduced with that commit, so we mark it as culprit to satisfy fix dependencies. Note: Point-to-point remote port is already handled separately and gets its N_Port_ID from the cached peer_d_id. So resetting port->d_id in general does not affect PtP. Link: https://lore.kernel.org/r/20220118165803.3667947-1-maier@linux.ibm.com Fixes: 799b76d09aee ("[SCSI] zfcp: Decouple gid_pn requests from erp") Cc: #2.6.32+ Suggested-by: Benjamin Block Reviewed-by: Benjamin Block Signed-off-by: Steffen Maier Signed-off-by: Martin K. Petersen Signed-off-by: Greg Kroah-Hartman --- drivers/s390/scsi/zfcp_fc.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) --- a/drivers/s390/scsi/zfcp_fc.c +++ b/drivers/s390/scsi/zfcp_fc.c @@ -521,6 +521,8 @@ static void zfcp_fc_adisc_handler(void * goto out; } + /* re-init to undo drop from zfcp_fc_adisc() */ + port->d_id = ntoh24(adisc_resp->adisc_port_id); /* port is good, unblock rport without going through erp */ zfcp_scsi_schedule_rport_register(port); out: @@ -534,6 +536,7 @@ static int zfcp_fc_adisc(struct zfcp_por struct zfcp_fc_req *fc_req; struct zfcp_adapter *adapter = port->adapter; struct Scsi_Host *shost = adapter->scsi_host; + u32 d_id; int ret; fc_req = kmem_cache_zalloc(zfcp_fc_req_cache, GFP_ATOMIC); @@ -558,7 +561,15 @@ static int zfcp_fc_adisc(struct zfcp_por fc_req->u.adisc.req.adisc_cmd = ELS_ADISC; hton24(fc_req->u.adisc.req.adisc_port_id, fc_host_port_id(shost)); - ret = zfcp_fsf_send_els(adapter, port->d_id, &fc_req->ct_els, + d_id = port->d_id; /* remember as destination for send els below */ + /* + * Force fresh GID_PN lookup on next port recovery. + * Must happen after request setup and before sending request, + * to prevent race with port->d_id re-init in zfcp_fc_adisc_handler(). + */ + port->d_id = 0; + + ret = zfcp_fsf_send_els(adapter, d_id, &fc_req->ct_els, ZFCP_FC_CTELS_TMO); if (ret) kmem_cache_free(zfcp_fc_req_cache, fc_req);