Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3028360rwb; Mon, 15 Aug 2022 16:26:49 -0700 (PDT) X-Google-Smtp-Source: AA6agR5blvXzNAMymZehEcXWNCyeTiZdTGzKdbUaQyVfg2LZvMwGJqeyEw24vgQ0LNXEp6IOe+g9 X-Received: by 2002:a17:903:1c7:b0:16f:1228:f632 with SMTP id e7-20020a17090301c700b0016f1228f632mr18882914plh.65.1660605926520; Mon, 15 Aug 2022 16:25:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660605926; cv=none; d=google.com; s=arc-20160816; b=sFOce/9wSKuib6TnuDZV4TV1mEjEjQf83tdHaUNNUFbSXXHXf1Yn46EBiDIu2rPGzO A5HJdDDTzhv3BM0hhUhJ6ZkXtoAi1KsgyDMPY7A3ztuPlorutyMnQU5skfp5nCIVoi9O +jsqVOx/8KuBM/2wKOEbbzLDaCvkSOoE1SpJLlAYrRsCwBQlCoJxkuAuQ+qbpIvoxUg3 ejDLY6R9mSEXh7hMa61sUxbpOzRFmCAFsfu1PdqrFD1pT7Uq2OR15S9gCHdzl8NT+p+c pTN9ipLN2sQuxkc+7zCBCyIRINcOLRyOTqyquUKThVl6GLtLdZ6lK95aH34PxU9/ydhP EN2Q== 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=4zmYfwwHUtA07dLoqDQ8VEV2BURr1iC2rA2nIiMK1e0=; b=SpwFAcO0TGFMpax8/GrW6qVnW0hsSbQXCJdB9hTzPSmKdAGbjgnIXRlQ3nGU2hUCIG 7b4jubtTCosk3TkHAx7QJARVu6tW6wdED+uXN+ah67mc43/EGyWI/3K6uQRqXXRmVIrK aHANC9CV/4aGfnCKsElEcSNI/gClhScsI96geKic5K+s+XIbcBux2IBn/D75q6C59KgP CkINfwUFlLxI13KPJ1zJC96f392ki/GVWEg15h5ZNZX41phIOUzC0RH0ctkO+YGMJjow O0qFOPbj0wXTYQqB2lROr90RCU5anC640E9YdUkRUBmGL9tF8F46A2Clcu+wbVqisQLw 2x3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Xd6mCglr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q7-20020a632a07000000b004223f3d5005si10886711pgq.120.2022.08.15.16.25.15; Mon, 15 Aug 2022 16:25:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Xd6mCglr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S241869AbiHOXJt (ORCPT + 99 others); Mon, 15 Aug 2022 19:09:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353231AbiHOXHa (ORCPT ); Mon, 15 Aug 2022 19:07:30 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64C82250; Mon, 15 Aug 2022 12:59:31 -0700 (PDT) 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 ams.source.kernel.org (Postfix) with ESMTPS id 600A7B80EB1; Mon, 15 Aug 2022 19:59:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ACA4DC433C1; Mon, 15 Aug 2022 19:59:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660593568; bh=/SbU5TgNUUjW574cJkQIC7C8/S1kgwxyehokC/ht1GA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Xd6mCglr8NfET1J3hauQ7mqfVUpQpCvKScElygYo7xqFpBKqFlIUrJzKaMMy0Ou6c 7YTGXshh1Cc0qDPGeHHSQ7G7QxZZTct4BF5WwM8L/lgsmWkFzqHkC9Du00lyR6pjjq 3Aa7YAw9Lrn+ArBMyaO/rkgyFpmRm7bkvoYzrT14= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arun Easi , Nilesh Javali , "Martin K. Petersen" Subject: [PATCH 5.18 0969/1095] scsi: qla2xxx: Fix losing target when it reappears during delete Date: Mon, 15 Aug 2022 20:06:08 +0200 Message-Id: <20220815180509.144944018@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arun Easi commit 118b0c863c8f5629cc5271fc24d72d926e0715d9 upstream. FC target disappeared during port perturbation tests due to a race that tramples target state. Fix the issue by adding state checks before proceeding. Link: https://lore.kernel.org/r/20220616053508.27186-8-njavali@marvell.com Fixes: 44c57f205876 ("scsi: qla2xxx: Changes to support FCP2 Target") Cc: stable@vger.kernel.org Signed-off-by: Arun Easi Signed-off-by: Nilesh Javali Signed-off-by: Martin K. Petersen Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/qla2xxx/qla_attr.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) --- a/drivers/scsi/qla2xxx/qla_attr.c +++ b/drivers/scsi/qla2xxx/qla_attr.c @@ -2716,17 +2716,24 @@ qla2x00_dev_loss_tmo_callbk(struct fc_rp if (!fcport) return; - /* Now that the rport has been deleted, set the fcport state to - FCS_DEVICE_DEAD */ - qla2x00_set_fcport_state(fcport, FCS_DEVICE_DEAD); + + /* + * Now that the rport has been deleted, set the fcport state to + * FCS_DEVICE_DEAD, if the fcport is still lost. + */ + if (fcport->scan_state != QLA_FCPORT_FOUND) + qla2x00_set_fcport_state(fcport, FCS_DEVICE_DEAD); /* * Transport has effectively 'deleted' the rport, clear * all local references. */ spin_lock_irqsave(host->host_lock, flags); - fcport->rport = fcport->drport = NULL; - *((fc_port_t **)rport->dd_data) = NULL; + /* Confirm port has not reappeared before clearing pointers. */ + if (rport->port_state != FC_PORTSTATE_ONLINE) { + fcport->rport = fcport->drport = NULL; + *((fc_port_t **)rport->dd_data) = NULL; + } spin_unlock_irqrestore(host->host_lock, flags); if (test_bit(ABORT_ISP_ACTIVE, &fcport->vha->dpc_flags)) @@ -2759,9 +2766,12 @@ qla2x00_terminate_rport_io(struct fc_rpo /* * At this point all fcport's software-states are cleared. Perform any * final cleanup of firmware resources (PCBs and XCBs). + * + * Attempt to cleanup only lost devices. */ if (fcport->loop_id != FC_NO_LOOP_ID) { - if (IS_FWI2_CAPABLE(fcport->vha->hw)) { + if (IS_FWI2_CAPABLE(fcport->vha->hw) && + fcport->scan_state != QLA_FCPORT_FOUND) { if (fcport->loop_id != FC_NO_LOOP_ID) fcport->logout_on_delete = 1; @@ -2771,7 +2781,7 @@ qla2x00_terminate_rport_io(struct fc_rpo __LINE__); qlt_schedule_sess_for_deletion(fcport); } - } else { + } else if (!IS_FWI2_CAPABLE(fcport->vha->hw)) { qla2x00_port_logout(fcport->vha, fcport); } }