linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: James Bottomley <James.Bottomley@HansenPartnership.com>,
	Tejun Heo <tj@kernel.org>
Cc: Alan Stern <stern@rowland.harvard.edu>,
	Sarah Sharp <sarah.a.sharp@linux.intel.com>,
	USB list <linux-usb@vger.kernel.org>,
	SCSI development list <linux-scsi@vger.kernel.org>,
	USB Storage List <usb-storage@lists.one-eyed-alien.net>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: Re: [usb-storage] UAS hangs khubd on USB disconnect
Date: Fri, 13 Dec 2013 22:24:33 +0100	[thread overview]
Message-ID: <52AB7B11.7020900@redhat.com> (raw)
In-Reply-To: <1386964999.2055.59.camel@dabdike.int.hansenpartnership.com>

Hi,

On 12/13/2013 09:03 PM, James Bottomley wrote:

<snip>

> Actually, I think I have this figured out.  There's a thinko in one of
> the scsi_target_reap() cases.  The original (and still existing) problem
> with targets is that nothing creates them and nothing destroys them, so,
> while we could rely on the refcounting of the device model to preserve
> the actual target object, we had no idea when to remove it from
> visibility.  That was the job of the reap reference, to track
> visibility.  It looks like the reap on device last put is occurring too
> late.  I think we should reap immediately after doing the sdev
> device_del, so does this fix the warn on? (I'm not sure because no-one
> has actually posted a backtrace, but it sounds like this is the
> problem).
>
> James
>
> ---
>
> diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
> index 8ff62c2..98d4eb3 100644
> --- a/drivers/scsi/scsi_sysfs.c
> +++ b/drivers/scsi/scsi_sysfs.c
> @@ -399,8 +399,6 @@ static void scsi_device_dev_release_usercontext(struct work_struct *work)
>   	/* NULL queue means the device can't be used */
>   	sdev->request_queue = NULL;
>
> -	scsi_target_reap(scsi_target(sdev));
> -
>   	kfree(sdev->inquiry);
>   	kfree(sdev);
>
> @@ -1044,6 +1042,8 @@ void __scsi_remove_device(struct scsi_device *sdev)
>   	} else
>   		put_device(&sdev->sdev_dev);
>
> +	scsi_target_reap(scsi_target(sdev));
> +
>   	/*
>   	 * Stop accepting new requests and wait until all queuecommand() and
>   	 * scsi_run_queue() invocations have finished before tearing down the

I've given this patch a try and it fixes the blk-tag.c: 89 BUG() I was seeing.

As for the other patch you (James) have send for that problem:

diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 8ff62c2..98d4eb3 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -399,8 +399,6 @@ static void scsi_device_dev_release_usercontext(struct work_struct *work)
  	/* NULL queue means the device can't be used */
  	sdev->request_queue = NULL;

-	scsi_target_reap(scsi_target(sdev));
-
  	kfree(sdev->inquiry);
  	kfree(sdev);

@@ -1044,6 +1042,8 @@ void __scsi_remove_device(struct scsi_device *sdev)
  	} else
  		put_device(&sdev->sdev_dev);

+	scsi_target_reap(scsi_target(sdev));
+
  	/*
  	 * Stop accepting new requests and wait until all queuecommand() and
  	 * scsi_run_queue() invocations have finished before tearing down the

That too fixes the blk-tag.c: 89 BUG() I was seeing. Either patch by itself
seems to be enough to fix this issue for me.

Thanks & Regards,

Hans

  parent reply	other threads:[~2013-12-13 21:24 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20131212000715.GA3181@xanatos>
2013-12-12 13:13 ` UAS hangs khubd on USB disconnect Hans de Goede
2013-12-12 22:04 ` [usb-storage] " Alan Stern
     [not found]   ` <Pine.LNX.4.44L0.1312121632470.849-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2013-12-13 18:09     ` Sarah Sharp
2013-12-13 18:19       ` Alan Stern
     [not found]         ` <Pine.LNX.4.44L0.1312131316470.1185-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2013-12-13 18:33           ` Tejun Heo
2013-12-13 19:18             ` James Bottomley
     [not found]               ` <1386962327.2055.54.camel-sFMDBYUN5F8GjUHQrlYNx2Wm91YjaHnnhRte9Li2A+AAvxtiuMwx3w@public.gmane.org>
2013-12-13 20:03                 ` James Bottomley
     [not found]                   ` <1386964999.2055.59.camel-sFMDBYUN5F8GjUHQrlYNx2Wm91YjaHnnhRte9Li2A+AAvxtiuMwx3w@public.gmane.org>
2013-12-13 20:22                     ` Hans de Goede
2013-12-13 21:06                   ` Alan Stern
2013-12-13 21:18                     ` James Bottomley
     [not found]                       ` <1386969529.2055.79.camel-sFMDBYUN5F8GjUHQrlYNx2Wm91YjaHnnhRte9Li2A+AAvxtiuMwx3w@public.gmane.org>
2013-12-14  0:48                         ` Alan Stern
2013-12-14  1:27                           ` James Bottomley
2013-12-14  3:00                             ` Alan Stern
2013-12-14  3:03                             ` [RFC] fix our current target reap infrastructure James Bottomley
2013-12-14  3:32                               ` Alan Stern
2013-12-14 23:55                                 ` James Bottomley
2013-12-15 21:32                                   ` Alan Stern
     [not found]                                     ` <Pine.LNX.4.44L0.1312151550380.32133-100000-pYrvlCTfrz9XsRXLowluHWD2FQJk+8+b@public.gmane.org>
2013-12-15 22:14                                       ` James Bottomley
     [not found]                                         ` <1387145674.2284.60.camel-sFMDBYUN5F8GjUHQrlYNx2Wm91YjaHnnhRte9Li2A+AAvxtiuMwx3w@public.gmane.org>
2013-12-16  2:44                                           ` Alan Stern
2013-12-16  3:32                                             ` James Bottomley
2013-12-16  2:49                                         ` Alan Stern
2013-12-16  3:33                                           ` James Bottomley
2013-12-13 21:13                   ` [usb-storage] UAS hangs khubd on USB disconnect Sarah Sharp
2013-12-13 21:24                   ` Hans de Goede [this message]
2013-12-13 20:05                 ` Alan Stern
2013-12-13 19:07           ` Sarah Sharp

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52AB7B11.7020900@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=sarah.a.sharp@linux.intel.com \
    --cc=stern@rowland.harvard.edu \
    --cc=tj@kernel.org \
    --cc=usb-storage@lists.one-eyed-alien.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).