Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp749219imm; Thu, 31 May 2018 08:45:03 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJBJD/OTmGKO916TUvXsnFE+yClfWqdtPiwLqXRYMQYquaIJ2yfjCnFC8rNN7BbdhAbm32P X-Received: by 2002:a65:5c09:: with SMTP id u9-v6mr5990148pgr.304.1527781503538; Thu, 31 May 2018 08:45:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527781503; cv=none; d=google.com; s=arc-20160816; b=MmOSArq9ODVm2K2RVAcsX5N+lkIGGZoOFSnv0JgBHAc8JAFgF3nJcgUnZ0YAjKyCK7 /2PCDfJLC98LhdXrqbK3oFvZsWd4xnDoRxlA+Ccs/5ye3OWM18ulBMeiH2YmpT6HjsDw WeJlHzPMsIujcoUDDMm5SyKPvN46wA/TzMjA2Ntr305xQGtKvJQVviFcTmFc/+e/EfKM asYNa08NO+sMC+FjCnobdTGQsT7iZzdw167112SGETXV56ya6EI8zLcVO/xlyJ7ddZ/Q xHFxrHnx8rZREr/TZ5pxSccxMx1tp4UNjh8vcVNwaFoi5apUSC1cPNIYFPwWwzLoMZNt yNew== 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=r6iWCR/ppwyOnkIXOBIAv16Vp45lzzJ02w4YsLkR2/M=; b=eiJm2k2XKiFJ8D0CBDxRSOMVQszX2c/kp1vqOHX2Jg0It6lUrr4+BmsCDPlzOeYLUT caIY2ao0InV1FBUg8MQlSxvaiXIpm8b4AUylmgAN8OSnu3G5WOcZep1XFjYMY0RDZHZH 6BTe8q8hyA6+ZY5UucddOmkbfpqApcearbxmZ8vS5bV2P7G3G/JwUEYmop4ryoeFyS0w D9jeslzfZ7DVqMVBNd5rr3X0sdSUbY9pWctWTcYX6p/vShRjI3YXHBAb4LpfrBiD+2RB yMz9hxw+ekzSI2HNaxvA3XYceTT/sIXCqggdTQ//Yv9hlKu4TU4D8OE2A/Iq5q7WSp1U G2wA== 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 b4-v6si29004140pgn.268.2018.05.31.08.44.48; Thu, 31 May 2018 08:45:03 -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 S1755535AbeEaPmx (ORCPT + 99 others); Thu, 31 May 2018 11:42:53 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:55550 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1755417AbeEaPmu (ORCPT ); Thu, 31 May 2018 11:42:50 -0400 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 9B0C813C8FC3B; Thu, 31 May 2018 23:42:45 +0800 (CST) Received: from [127.0.0.1] (10.202.227.238) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.382.0; Thu, 31 May 2018 23:42:37 +0800 Subject: Re: [PATCH 4/8] scsi: libsas: trigger a new revalidation to discover the device To: Jason Yan , , References: <20180529022309.21071-1-yanaijie@huawei.com> <20180529022309.21071-5-yanaijie@huawei.com> CC: , , , , , , , , , , , , Ewan Milne , Tomas Henzl From: John Garry Message-ID: <013c5c91-9792-7951-95ed-22daae2e2dbe@huawei.com> Date: Thu, 31 May 2018 16:42:29 +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-5-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: > Now if a new device replaced a old device, the sas address will change. > We unregister the old device and discover the new device in one > revalidation process. But after we deferred the sas_port_delete(), the > sas port is not deleted when we registering the new port and device. > This will make the sysfs complain of creating duplicate filename. > > Fix this by doing the replacement in two steps. The first revalidation > only delete the old device and trigger a new revalidation. The second > revalidation discover the new device. > > 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 | 11 ++++++++++- > 1 file changed, 10 insertions(+), 1 deletion(-) > > diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c > index 629c580d906b..25ad9ef54e6c 100644 > --- a/drivers/scsi/libsas/sas_expander.c > +++ b/drivers/scsi/libsas/sas_expander.c > @@ -2013,6 +2013,8 @@ static int sas_rediscover_dev(struct domain_device *dev, int phy_id, bool last) > { > struct expander_device *ex = &dev->ex_dev; > struct ex_phy *phy = &ex->ex_phy[phy_id]; > + struct asd_sas_port *port = dev->port; > + struct asd_sas_phy *sas_phy; > enum sas_device_type type = SAS_PHY_UNUSED; > u8 sas_addr[8]; > int res; > @@ -2060,7 +2062,14 @@ static int sas_rediscover_dev(struct domain_device *dev, int phy_id, bool last) > SAS_ADDR(phy->attached_sas_addr)); > sas_unregister_devs_sas_addr(dev, phy_id, last); > > - return sas_discover_new(dev, phy_id); > + /* force the next revalidation find this phy and bring it up */ > + phy->phy_change_count = -1; > + ex->ex_change_count = -1; > + sas_phy = container_of(port->phy_list.next, struct asd_sas_phy, > + port_phy_el); > + port->ha->notify_port_event(sas_phy, PORTE_BROADCAST_RCVD); > + This is less than ideal: that is, restarting another discovery with this artifical broadcast event. We do something similar when re-enabling revalidation. Can we do all the event processing synchronised to the original event? > + return 0; > } > > /** >