Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp38160imm; Thu, 31 May 2018 18:00:43 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLVe56b/l5auAnXfjrVFavKwdgHBv+6LoExhbzh7pcPcIgiEIagEXjOyv2U4TrDzWWfbfij X-Received: by 2002:a62:4141:: with SMTP id o62-v6mr8730840pfa.111.1527814843799; Thu, 31 May 2018 18:00:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527814843; cv=none; d=google.com; s=arc-20160816; b=i9G8VjMqrJDq2nhNGVFjRUUwFXTjdAs+FdLIwmltBqCWMD5gma5Q8A4RS9vDyzkFqR rln1i1kASAR8ij0RHETcmrvNzN0SDlItWomIPad2Xw8C93nCCIr6UD/WXN8g71KIVI1q JtLj5TaAYNO33DETtuHVPNaEHcIA41sTcTPimynbjLytxGly192U9FZt6GmhEKXb9l0S hTFP5F3zkXv3FHpOq/UouC8a1RAhCvC3rxrl6/1eyCg2sLUAFfs5DHxcpnkurNNQZG/9 SULc4LDZ3jUj7JPCl0j6ewasXXCl40Rb/GTZtj+KsPOr2inv+I/W3FReor4VzQ2Y+x8z 8qFw== 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=E9DFmnT2/nvq9PgF7wxWnKivKtjP3S/fCkoeG25SHxo=; b=cGhFHhWyGv87d5Qv4WeyCmAmRynBNuPEnW4Z+uM0hIetqh4hPRU/hKa8zczNgPxmTO xMG2qOx4ny4eGrUxR/FiphBabtH5Ry3ukyuzPwKBLyJhm0b4ryYNKrj0gsFIOadpAIX7 DdDzUzNAfZYVFtqjkE4H+5YUVSkUFnYmlptY07susJxlRCqypHaFwSW0TaGq1j8v+cpT E6jANYOCPycqNLCZU0jdzAUH14qGP24sd5o3AjlGxtosvixUROEEdOMglpfCVGfuShvT EunzKOouyrZS9eCHr6DFREYKAc7c1IMZlHcNOYXtdY6Hn7gW63LqcrZQypIO0RWe60C5 ec4A== 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 f18-v6si30453291pgt.63.2018.05.31.18.00.29; Thu, 31 May 2018 18:00:43 -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 S1750929AbeFABAB (ORCPT + 99 others); Thu, 31 May 2018 21:00:01 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:8244 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750771AbeFAA75 (ORCPT ); Thu, 31 May 2018 20:59:57 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 986DDCA37B17D; Fri, 1 Jun 2018 08:59:43 +0800 (CST) Received: from [127.0.0.1] (10.177.96.203) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.382.0; Fri, 1 Jun 2018 08:59:38 +0800 Subject: Re: [PATCH 4/8] scsi: libsas: trigger a new revalidation to discover the device To: John Garry , , References: <20180529022309.21071-1-yanaijie@huawei.com> <20180529022309.21071-5-yanaijie@huawei.com> <013c5c91-9792-7951-95ed-22daae2e2dbe@huawei.com> CC: , , , , , , , , , , , , Ewan Milne , Tomas Henzl From: Jason Yan Message-ID: <5B109A79.6060907@huawei.com> Date: Fri, 1 Jun 2018 08:59:37 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <013c5c91-9792-7951-95ed-22daae2e2dbe@huawei.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.96.203] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018/5/31 23:42, John Garry wrote: > 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. > That will back to what we have discussed before. The sas port adding/removing is delayed outside the disco_mutex. we can only do the adding or removing once inside the disco_mutex. > Can we do all the event processing synchronised to the original event? > Actually bcast is a very special event, and what we do in revalidation at one time is scanning all phy changes, which may include many bcast events(especially before our first patchset), and the next revalidations may have nothing to do. So "do all the event processing synchronised to the original event" is impossible actually. Maybe if the bcast can indicate which device originated it, we will achieve this goal. But if you mean we shall do this device removing and rediscovering in one revalidation if it is not a "flutter", I think we can wrap a new function for sas_revalidate_domain(), such as: while (need_to_revalidate_again) need_to_revalidate_again = sas_revalidate_domain() In this way the sas_port adding/removing is packed in one loop, we won't have the annoyance of "duplicate filename" warning. What do you think? >> + return 0; >> } >> >> /** >> > > > > . >