From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932507AbdC2Lyr (ORCPT ); Wed, 29 Mar 2017 07:54:47 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:4809 "EHLO dggrg01-dlp.huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S932251AbdC2Lyo (ORCPT ); Wed, 29 Mar 2017 07:54:44 -0400 Subject: Re: [PATCH 1/2] scsi: sas: flush destruct workqueue on device unregister To: Johannes Thumshirn References: <9580eaf323f5da17dcace9e32b22a1df4099961d.1490775958.git.jthumshirn@suse.de> <02778435-6c67-0ac9-2faa-03ebb7934477@huawei.com> <20170329112922.GB9183@linux-x5ow.site> CC: "Martin K . Petersen" , Tejun Heo , James Bottomley , Dan Williams , Jack Wang , "Hannes Reinecke" , Linux SCSI Mailinglist , Linux Kernel Mailinglist From: John Garry Message-ID: <343ddf8b-70e0-32f8-6ab8-31479729f827@huawei.com> Date: Wed, 29 Mar 2017 12:53:28 +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: <20170329112922.GB9183@linux-x5ow.site> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.203.181.155] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090201.58DBA043.00AA,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: f3ba24c2ecd4c41c5bc3cfb97acc0092 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 29/03/2017 12:29, Johannes Thumshirn wrote: > On Wed, Mar 29, 2017 at 12:15:44PM +0100, John Garry wrote: >> On 29/03/2017 10:41, Johannes Thumshirn wrote: >>> In the advent of an SAS device unregister we have to wait for all destruct >>> works to be done to not accidently delay deletion of a SAS rphy or it's >>> children to the point when we're removing the SCSI or SAS hosts. >>> >>> Signed-off-by: Johannes Thumshirn >>> --- >>> drivers/scsi/libsas/sas_discover.c | 4 ++++ >>> 1 file changed, 4 insertions(+) >>> >>> diff --git a/drivers/scsi/libsas/sas_discover.c b/drivers/scsi/libsas/sas_discover.c >>> index 60de662..75b18f1 100644 >>> --- a/drivers/scsi/libsas/sas_discover.c >>> +++ b/drivers/scsi/libsas/sas_discover.c >>> @@ -382,9 +382,13 @@ void sas_unregister_dev(struct asd_sas_port *port, struct domain_device *dev) >>> } >>> >>> if (!test_and_set_bit(SAS_DEV_DESTROY, &dev->state)) { >>> + struct sas_discovery *disc = &dev->port->disc; >>> + struct sas_work *sw = &disc->disc_work[DISCE_DESTRUCT].work; >>> + >>> sas_rphy_unlink(dev->rphy); >>> list_move_tail(&dev->disco_list_node, &port->destroy_list); >>> sas_discover_event(dev->port, DISCE_DESTRUCT); >>> + flush_work(&sw->work); >> >> I quickly tested plugging out the expander and we never get past this call >> to flush - a hang results: > > Can you activat lockdep so we can see which lock it is that we're blocking on? > I have it on: CONFIG_LOCKDEP_SUPPORT=y CONFIG_LOCKD=y CONFIG_LOCKD_V4=y > It's most likely in sas_unregister_common_dev() but this function takes two spin > locks, port->dev_list_lock and ha->lock. > We can see from the callstack I provided that we're working in workqueue scsi_wq_0 and trying to flush that same queue. Much appreciated, John > Thanks a lot, > Johannes >