Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5127028imm; Wed, 12 Sep 2018 01:18:32 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYOZrwbIl+GsOflkOQjnVViHOlHSVU4aDdCGjGzPLrivfp1xCWZ61vIyfCdvgpGJ+Uc1QSl X-Received: by 2002:a62:8d16:: with SMTP id z22-v6mr864836pfd.181.1536740312496; Wed, 12 Sep 2018 01:18:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536740312; cv=none; d=google.com; s=arc-20160816; b=SLJANGkEx8/tcq1r0RlgYiGLJiUlltQ3Z7eamGCT8GAw1sMFjuKHQLvaUk5l/PYI6K 6wu53NnD7SybrYxIss/6DgJaecg5BEP8J4sWDjOJ8TcXCIb0udzUkXjEmG0MNQWE8Hjy HaNsEuPVKpQtL/Ba5yhPYRLRnTh/t7QAdPTx1voU5S43ixPZu0N50Mk3Xgaz7tcEIVkI mMGx6T5LXw8mHv6xNsISoJQc0cpXk9vJONaOhRkSQC2ERKAuTqdkyLqhR7HfscprtYwn rWO1qfmx5kZXRJqi4R5SPvti/dDNTy1aCygNpvi5SJYkwNKRKjVfftykMexkU8LECn9o jLog== 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=LPzbfx2mvgL7NxmR/8dUPEnV+oGr3Coe6pMo44Q9w24=; b=S/0PXYigJr0fL17707coDlewpbX+A+ZujNzkGqJHrL/3JX0alQfON1iC4bdCFnHuHr eH4T3Q9ylzW1CETNoPzLunzVYrh44x9gsZg9vbL6EST0OSE+6PB36HlULA/hqmvFQS78 3DDLB8gHmH2SyQbN5sezxkciWGAZXWrPdGwzMpL4wuI8Z+VWYuZRWCy289VfGV3CnEGL rVntug13pra/2HkPvyfNNaQz/x4qaNJ07U90BOMjLpxrYBelAIAdwCdvWuXFZ5x+E4Ac vQkhXYxQbMeey0IIMDCcYzE83r88w2wC2AI1vxnYshsCL9kQB0UpuXEs6d5T61achqOs l0Kg== 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 o1-v6si329579pld.223.2018.09.12.01.18.17; Wed, 12 Sep 2018 01:18:32 -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 S1727824AbeILNVA (ORCPT + 99 others); Wed, 12 Sep 2018 09:21:00 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:11689 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726537AbeILNVA (ORCPT ); Wed, 12 Sep 2018 09:21:00 -0400 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 1703B24B318DB; Wed, 12 Sep 2018 16:17:33 +0800 (CST) Received: from huawei.com (10.175.124.28) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.399.0; Wed, 12 Sep 2018 16:17:24 +0800 From: Jason Yan To: , CC: , , , , , , , , , , , Jason Yan , Ewan Milne , Tomas Henzl Subject: [PATCH 3/5] scsi: libsas: always unregister the old device if going to discover new Date: Wed, 12 Sep 2018 16:29:44 +0800 Message-ID: <20180912082946.34814-4-yanaijie@huawei.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180912082946.34814-1-yanaijie@huawei.com> References: <20180912082946.34814-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 --- 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