Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753247AbcDNCG0 (ORCPT ); Wed, 13 Apr 2016 22:06:26 -0400 Received: from mail-pa0-f44.google.com ([209.85.220.44]:33206 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751010AbcDNCGY (ORCPT ); Wed, 13 Apr 2016 22:06:24 -0400 Date: Thu, 14 Apr 2016 11:07:52 +0900 From: Sergey Senozhatsky To: James Bottomley Cc: Johannes Thumshirn , Sergey Senozhatsky , "Ewan D. Milne" , Hannes Reinecke , "Martin K. Petersen" , Stephen Rothwell , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, linux-next@vger.kernel.org, Sergey Senozhatsky , Xiong Zhou Subject: Re: [-next] BUG_ON in scsi_target_destroy() Message-ID: <20160414020752.GA516@swordfish> References: <20160411090146.GA537@swordfish> <2201725.I2to9GCRQJ@c203> <1460560474.2322.3.camel@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1460560474.2322.3.camel@linux.vnet.ibm.com> User-Agent: Mutt/1.6.0 (2016-04-01) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1189 Lines: 37 Hello, On (04/13/16 08:14), James Bottomley wrote: [..] > How about good grief no! A device with multiple targets will get it's > lists screwed with this > > The STARGET_REMOVE state you added only applies to the case we're > trying to kill a target. In the natural operation case, which is what > everyone else is running into, we will try to remove a running target > when it has no more scsi devices left on it. So the correct patch > should be to make the BUG_ON see this: works for me. Reported-and-tested-by: Sergey Senozhatsky -ss > James > > --- > > diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c > index 27df7e7..e0a78f5 100644 > --- a/drivers/scsi/scsi_scan.c > +++ b/drivers/scsi/scsi_scan.c > @@ -319,8 +319,7 @@ static void scsi_target_destroy(struct scsi_target *starget) > struct Scsi_Host *shost = dev_to_shost(dev->parent); > unsigned long flags; > > - BUG_ON(starget->state != STARGET_REMOVE && > - starget->state != STARGET_CREATED); > + BUG_ON(starget->state == STARGET_DEL); > starget->state = STARGET_DEL; > transport_destroy_device(dev); > spin_lock_irqsave(shost->host_lock, flags); >