Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2962052imm; Mon, 28 May 2018 21:02:51 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqurrDqb7XH2m2YkF/mxGTCPmDSR11kLJFkIFxKGZF+nxb3Ch7AVhIRcknHrGUBX8EffF5v X-Received: by 2002:a63:6e84:: with SMTP id j126-v6mr12561935pgc.239.1527566571292; Mon, 28 May 2018 21:02:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527566571; cv=none; d=google.com; s=arc-20160816; b=L1E4fHqdpAIBdDeZyn6XTMgXie3y1onbx/9KIeiVyah8vT2N61LwioJCb31TdBL78B iCnkHuIXcrrsi4QiYyrH1zJv1A49xfCUn4cyjrazeGgTqT5X8ptLh4zMheIOvW2vPjQD 40GJE71AWg2coaPbiVe9eA/uw7tGwSXtarM31XIBlyS0zypIWpho3KoJtM1BbL38a8yG m16J1jz4HMuSFiQAjv71woWs/N1ef/7aR0M1qhWVcOnUAkYDNAu2xLp5RvxoSXVYPhAI E69X2wqGCl5BDen2Ln6YrmxgMNgM+3mJnyQaE07c/GEpUItaij/7mXQtc7p0+xv6dFoe FzXw== 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:arc-authentication-results; bh=NGtV3rAx5UMfKf/lBdjC6SJYRdh9XI5eozpYZawc4/4=; b=IfGLXDfpuLenXLXw8hONRkhrQ23xKPpc4d/AcxowBxZSvZvVto2+FH+i8WF+6YcPsF l04sCwm9NLbNc59g64O967LW5DAmJnm3JIaxTt6A0mzdg8ebglqG7VMCyMW+Xc0BVfW5 +wao3UVnW1Gq5d083mgkdzNeAYQcrDURMAC6gRD/XWhRUONVXrsEVLmarOBQZ5jnKvhK CZtpNappdbnDU9izGo985lv4DMANoELHOmorzJrxxc2VBNDkvPhnHATUowSxE8sHXjkR exTtZxW+pT21DZEzU3Ra2s4IOzw3geaYgnY45ExSuY924oFGqmUpuJH3pWyoWocZOgbm fAwg== 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 v61-v6si31831565plb.499.2018.05.28.21.02.36; Mon, 28 May 2018 21:02:51 -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 S933983AbeE2COd (ORCPT + 99 others); Mon, 28 May 2018 22:14:33 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:8199 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756024AbeE2COU (ORCPT ); Mon, 28 May 2018 22:14:20 -0400 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 07863F9009794; Tue, 29 May 2018 10:14:07 +0800 (CST) Received: from huawei.com (10.175.124.28) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.382.0; Tue, 29 May 2018 10:14:02 +0800 From: Jason Yan To: , CC: , , , , , , , , , , , , , Jason Yan , Ewan Milne , Tomas Henzl Subject: [PATCH 3/8] scsi: libsas: always unregister the old device if going to discover new Date: Tue, 29 May 2018 10:23:04 +0800 Message-ID: <20180529022309.21071-4-yanaijie@huawei.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180529022309.21071-1-yanaijie@huawei.com> References: <20180529022309.21071-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 --- 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 8b7114348def..629c580d906b 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.13.6