Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3099283rwb; Mon, 15 Aug 2022 18:05:06 -0700 (PDT) X-Google-Smtp-Source: AA6agR53nKaBFxRocklr5iylx2vlJ9Q3xeEovcfHyLucFfsXLqD1fUCfYGYg3b1f6xm2QydfmUUu X-Received: by 2002:a17:907:12d7:b0:730:6d62:4ef7 with SMTP id vp23-20020a17090712d700b007306d624ef7mr11493255ejb.133.1660611906256; Mon, 15 Aug 2022 18:05:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660611906; cv=none; d=google.com; s=arc-20160816; b=EqSCjawsnnCau8X0uKiZfsTQHw7Knz+obPZlbcusAwaMmfoagFi0/95N5FLmB5Dyu2 SCm7s2cN+EphYc1y8cJITqDaPyEF+vfNE0W5c2mrYDFz2Q+Gh4U6pJcRLtlJIRMFYnat 1BZwJ0DZguAq84aI5lM4o/yTMNfXw6qjtoH+mlnKiwIgD+zT3OA6bc6+kIguQ0oDoaXv l3wlMJqxD7ifGaPM+rqbpKl873m6CT6oh25XAUwZSGI78G5HeSnbUq/iZAKnX//qhpR6 ViyofbBgYYu688rwj7dZKVr/kM2VcOllCJeOrEchYo8jYInDosPtuxt09FeaADtKJHUq R8fQ== 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=YCSjbMOW6oOSze5Fufu3y/pyTvyR3qHoPLykpnPOrNvCX6r7RT51aCIg/XENCWlfdz 9DQheJdjIBuvZzK4SULI1e75/AgIlXRYPxoEcf7x4ytV9P/fHqWjkqpkgDr0I/sStTqa BunkRZ3f6LcQHt7BIJXPFBCZUhYfKhDOtqx7X6t4wepq3oLJA1UsugwNeyixEXWGOaWC gAXvGt17RwqUK4QadjhqHSgWQW/a7027N6Cupdx70VrEEl+l2KG4MkThj429A9aldEZU 2A/el+0m3Va378EOOMLb5bQvC4hNFBbgUDdVvsG0eCobVm6eH8QvMqOFZQHBaA6UYMlV 1PPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xRVirIbO; 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 e10-20020aa7d7ca000000b0043d708d50c2si8421849eds.159.2022.08.15.18.04.28; Mon, 15 Aug 2022 18:05:06 -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=xRVirIbO; 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 S245291AbiHPBA3 (ORCPT + 99 others); Mon, 15 Aug 2022 21:00:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348832AbiHPAwO (ORCPT ); Mon, 15 Aug 2022 20:52:14 -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 9914919C9E9; Mon, 15 Aug 2022 13:47:45 -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 9ABA8B811A1; Mon, 15 Aug 2022 20:47:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E1E8FC4315C; Mon, 15 Aug 2022 20:47:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660596462; bh=/SbU5TgNUUjW574cJkQIC7C8/S1kgwxyehokC/ht1GA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xRVirIbOJ23kkvgnPjjeljVjypRqUlSqCC5hnAe28jKeGNDEJ5Y5Im8uApHTebkK9 pm81iACjXFxS5HM095W8BbRmYK7HpuWyhfmJST53qIwmsmfbv1oiXKvbYcGQGSChvL MLFmLBXKTCnUumQQIJxnObgc5DHyLoGoEHSj2JJQ= 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.19 1043/1157] scsi: qla2xxx: Fix losing target when it reappears during delete Date: Mon, 15 Aug 2022 20:06:39 +0200 Message-Id: <20220815180521.741682878@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@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); } }