Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp715618imm; Thu, 31 May 2018 08:11:23 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKEUBfQWoI59xUUusgbZnAsj/WvJtPs/ySmU//G5PPuFqRGdsrzj0Zci5sZ5P3whKRJkMkI X-Received: by 2002:a62:9c93:: with SMTP id u19-v6mr7278232pfk.74.1527779483682; Thu, 31 May 2018 08:11:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527779483; cv=none; d=google.com; s=arc-20160816; b=aXWeA+s2EWMSMb5wL7l2hU7MT8kURfopj6ZOyQgOfgJxV3rZHFmNrD1Ggyc56pJKBq Y08ENY3wc5JfdzO9Iag2bqz/AxvzXGZ7JXs/TStVWED2EF9ZHJNhVhXtjZITPD0IafHe toSLJsVMjGJc+QrviMgzY9u1+T3XWodu6wTeFywOJIUxqEG6WW3mxs2JIn/puZnZl2qn MJT839FZm6s5cRnKO63AQFdSyYG1wjN1ziKMC5mdAX8DWaDMbD5uqoeV/LDFAjgu92eu MW5EQHaGq365GW5YYwhaZ/GOVEMHIyYVkB6zl5X6eH+UgNumHerhtkLG1r/vTN+qC2d9 DjmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject:arc-authentication-results; bh=1snxsIGEPpLm63EUUk7hLE4bsMqDAqdMqsY55vb1GnM=; b=0xaG7lh6viCGJ3dOyXX/IigzrZKp8qDHka+Xrs4n7jYMhefl1cM0KgafPRvezgYC5Y EyBDmuseKlsmhrNoU18QugwmixaZRM/NymKWy3nZKGQ+i/I7uXXvlMYCBr8fTLbafbtw TYy3B6nFuMbWjqrcC0WtFtHmz6yO/p/M+2+R42MlXcMtvZI6AGNPMWnm0njgznkO2I17 eOftnYfO/84f2o60qCTxgW/Kqn3V3qG1XbqtdehPFX0UrlBM7ZFHtmMsdAN6LHMUetHC hliY5lntVWQtYhmf/QzuzfA8qZtTPKI29nE9TZNjLQwH+Tg42Ro6M7Yvjp3Rv2VejfhJ 1VqQ== 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 a16-v6si10372525pgd.380.2018.05.31.08.11.09; Thu, 31 May 2018 08:11:23 -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 S1755506AbeEaPK0 (ORCPT + 99 others); Thu, 31 May 2018 11:10:26 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:8179 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755484AbeEaPKY (ORCPT ); Thu, 31 May 2018 11:10:24 -0400 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 1409EF33FD49A; Thu, 31 May 2018 23:10:10 +0800 (CST) Received: from [127.0.0.1] (10.202.227.238) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.382.0; Thu, 31 May 2018 23:10:05 +0800 Subject: Re: [PATCH 3/8] scsi: libsas: always unregister the old device if going to discover new To: Jason Yan , , References: <20180529022309.21071-1-yanaijie@huawei.com> <20180529022309.21071-4-yanaijie@huawei.com> CC: , , , , , , , , , , , , Ewan Milne , Tomas Henzl From: John Garry Message-ID: <8d3c7ee0-b76e-841f-b8e3-0346d22ae0b7@huawei.com> Date: Thu, 31 May 2018 16:09:56 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: <20180529022309.21071-4-yanaijie@huawei.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.202.227.238] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 29/05/2018 03:23, Jason Yan wrote: > 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); > - } The preceeding checks in code check for no device/comm fail or SATA flutter. If we're rediscovering the device and the SAS address has not changed, then why previously still try to discover a new device? I'm guessing sas_discover_new() had no affect in this case, since maybe since the PHY was already discovered. But that would not make sense since you say "we are going to register a new one". Or, if we are always going to register a new one, how did we ensure we always unregistered the old device previously (when SAS address did not change)? > + /* 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); > } >