Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp226979imm; Tue, 18 Sep 2018 20:33:32 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbSuGTQKtkRM3hH+WDTd5IqG1FMX00ABTvryflKdQFn2VagtB9VPvwA1U5woKUMYCL7ntCm X-Received: by 2002:a62:401:: with SMTP id 1-v6mr33588226pfe.28.1537328012772; Tue, 18 Sep 2018 20:33:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537328012; cv=none; d=google.com; s=arc-20160816; b=q2+m2hsXfm3Fm8ehSF0U5Rb0D26DP2ekX/CWpnB9k8hoEbk70OcyfDMCRpN28XFKin nOHMZc5wf7eD603OqTpsP/xQdF8WjZtg866++B2mNXdJRsycTJOrIXvWUeMwh3MXjqMF SODr09ZjdLT8TScQvz1C0m+wZzkmWBb6MFCOKpt/m/Nn+oCV80pRpBppR9jLzh80SqjK luAv9mypiYcWDFlh7kd621eP8fsHX8WFf6yuKMlAg8MN/8JSERL4MkdlkQlWtzQg+Okk X9rqORPGPWrqG2doqP3XEb9vlfgIdCiaqwfkhnqsu78/5gU9fx16jCipKr4v9m6p0UFG FNyQ== 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=AP1hu8On8Kz7pEU2Mt5Qb3BdwYvXPCe7zp2ywvAvPN9x6ks3CO+561utK3tYVr0BXB zoZoDlxk745tQlWsXDIy+ucqS+rGzwr4x+TF6DVQUQzArhTNrkjsy83CBvZgQhEjH/Kx 7W0A/E5QFxzZwvugk3rBqHI9mEiS75aYYHAtOaL0XSap2v/dULTRDHML3Rtm0KBwcjrB a7G+IfZq19Msq3ncPc4HiTXChCZqxtiTYM2xevt7B9T+jgZ9QOf2ms9NAMdxmVPiC7sB C13NcQUB/VD5V9TvdK1VhnhmecH8795yNivm99vw63PzsteiisjLSqi4aBNJT16p/zg4 OaRQ== 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 e1-v6si20373851pld.408.2018.09.18.20.33.03; Tue, 18 Sep 2018 20:33: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 S1729926AbeISJIt (ORCPT + 99 others); Wed, 19 Sep 2018 05:08:49 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:55047 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726044AbeISJIs (ORCPT ); Wed, 19 Sep 2018 05:08:48 -0400 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 54183A7F52BD4; Wed, 19 Sep 2018 11:32:55 +0800 (CST) Received: from huawei.com (10.175.124.28) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.399.0; Wed, 19 Sep 2018 11:32:50 +0800 From: Jason Yan To: , CC: , , , , , , , , , , , Jason Yan , Ewan Milne , Tomas Henzl Subject: [PATCH v2 3/5] scsi: libsas: always unregister the old device if going to discover new Date: Wed, 19 Sep 2018 11:32:02 +0800 Message-ID: <20180919033204.11102-4-yanaijie@huawei.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180919033204.11102-1-yanaijie@huawei.com> References: <20180919033204.11102-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