Received: by 2002:a4a:301c:0:0:0:0:0 with SMTP id q28-v6csp239496oof; Mon, 24 Sep 2018 19:44:03 -0700 (PDT) X-Google-Smtp-Source: ACcGV61G7dK8k0Z//DL+xjoy0o9RRSdoDejlGMdGz6WEq6jMKeaTJaXkutJfbjcp/sxmwMcfOMDj X-Received: by 2002:a63:1b52:: with SMTP id b18-v6mr1249437pgm.303.1537843442924; Mon, 24 Sep 2018 19:44:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537843442; cv=none; d=google.com; s=arc-20160816; b=VzEL0MdNIjaHya5xM3X9c1artPVVxsorQNbrTpRa9kRfnK5HO1XqyuWedxLR6Lu8js /EUMVH3KXZhDzCjWEN7ABpMIAJ876IOvzyHtWGpr/V9qU0cqq451aEmE9iHly3Ik5rJd Pb2u2RWOXbH7J7s0JeCa/WlL1BcyEhNs1giWZH8ygR6ZZwyqHpRs+KW0EK4dD7h41Oxx wFty/xJUWIpzlkMZ2aImYP2IIOP2lqxD0FuWm0r+q32KDAVtqu0lpmm4iZQAGZf1kvXv JGOohXSiZpuD2ioote+FxL82n1NsjUvkJvKq93YbN92Q4J/zSHbAwo/1xb+Ob3OgRMMs 2I1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=unPaKRdASkksNarKUKPN/8pfQ1EmPEaQ5URtGrJt2bY=; b=MauX+tXSaukQMrpShUex71HqCznnxF1oTQBBbCQbBVb+ptpR/6J8c1/pMGN3fK+WCW J0GgEW+f3syCuOguyykCB7ojKM0QUyahjPXScH9U0+I9nZ75tZ0FXE2cZ9vfClf6eOoj zg871pfycgprZ1uWNiccAGWNEH9miqTBNeYxo2nW1b8gy4z2Vm8hJf6KQg2azC08emET 9cdRhnT3k/9Is3im9GTjRMEjYPar+mcfYVYMTJCJI8A6/uNr1qyER2Ldv2LkKdvzcnBv JY+WSmK9m3jRKRtDDZVoHaKpWLp/nwF0FzsfV7k8htFSr4wWlWqGJnm3fGEhDJNa6Yrk WAxQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j4-v6si371310pfg.62.2018.09.24.19.43.47; Mon, 24 Sep 2018 19:44:02 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728282AbeIYIsr (ORCPT + 99 others); Tue, 25 Sep 2018 04:48:47 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:53463 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727524AbeIYIsq (ORCPT ); Tue, 25 Sep 2018 04:48:46 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 3D0749AB5E270; Tue, 25 Sep 2018 10:43:27 +0800 (CST) Received: from huawei.com (10.175.124.28) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.399.0; Tue, 25 Sep 2018 10:43:19 +0800 From: Jason Yan To: , CC: , , , , , , , , , , , Jason Yan , Ewan Milne , Tomas Henzl Subject: [PATCH v3 3/5] scsi: libsas: always unregister the old device if going to discover new Date: Tue, 25 Sep 2018 10:56:52 +0800 Message-ID: <20180925025654.44053-4-yanaijie@huawei.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180925025654.44053-1-yanaijie@huawei.com> References: <20180925025654.44053-1-yanaijie@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.124.28] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If we went into sas_rediscover_dev() the attached_sas_addr was already insured not to be zero. So it's unnecessary to check if the attached_sas_addr is zero. And although if the sas address is not changed, we always have to unregister the old device when we are going to register a new one. We cannot just leave the device there and bring up the new. Signed-off-by: Jason Yan CC: chenxiang CC: John Garry CC: Johannes Thumshirn CC: Ewan Milne CC: Christoph Hellwig CC: Tomas Henzl CC: Dan Williams CC: Hannes Reinecke Reviewed-by: Johannes Thumshirn Reviewed-by: Hannes Reinecke --- drivers/scsi/libsas/sas_expander.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c index fadc99cb60df..52222940d398 100644 --- a/drivers/scsi/libsas/sas_expander.c +++ b/drivers/scsi/libsas/sas_expander.c @@ -2054,14 +2054,11 @@ static int sas_rediscover_dev(struct domain_device *dev, int phy_id, bool last) return res; } - /* delete the old link */ - if (SAS_ADDR(phy->attached_sas_addr) && - SAS_ADDR(sas_addr) != SAS_ADDR(phy->attached_sas_addr)) { - SAS_DPRINTK("ex %016llx phy 0x%x replace %016llx\n", - SAS_ADDR(dev->sas_addr), phy_id, - SAS_ADDR(phy->attached_sas_addr)); - sas_unregister_devs_sas_addr(dev, phy_id, last); - } + /* we always have to delete the old device when we went here */ + SAS_DPRINTK("ex %016llx phy 0x%x replace %016llx\n", + SAS_ADDR(dev->sas_addr), phy_id, + SAS_ADDR(phy->attached_sas_addr)); + sas_unregister_devs_sas_addr(dev, phy_id, last); return sas_discover_new(dev, phy_id); } -- 2.14.4