Linux USB
 help / color / mirror / Atom feed
From: Alan Stern <stern@rowland.harvard.edu>
To: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
Cc: James Dutton <james.dutton@gmail.com>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>
Subject: Re: USB disk disconnect problems
Date: Sun, 21 Aug 2022 15:03:43 -0400	[thread overview]
Message-ID: <YwKBj94XtgU70crx@rowland.harvard.edu> (raw)
In-Reply-To: <CAA6KcBC2wEc78fgrMLBfbyEinR3rVUY6z8HeUbE=wtv0c4BP2Q@mail.gmail.com>

On Sun, Aug 21, 2022 at 11:42:00AM -0700, Matthew Dharm wrote:
> On Sun, Aug 21, 2022 at 7:47 AM Alan Stern <stern@rowland.harvard.edu>
> wrote:
> 
> > On Sun, Aug 21, 2022 at 12:17:30PM +0100, James Dutton wrote:
> > > I know my suggested behaviour might be detrimental for some users, in
> > > case one modifies the usb disk in another computer and then comes
> > > back, but I would like an option that assumes it has not been plugged
> > > into anything else.
> 
> 
> In the “old days” (that is, my original design for use-storage) it used to
> do exactly what you are looking for - based on VID, DID, and SerialNumber
> it would “remember” devices. The SCSI host would never be destroyed, and
> when a device re-appeared it would be re-connected to the existing host.

Ah yes...  I do remember those days, but not very often.  :-)

> That caused all sorts of problems. The SCSI and block layers just couldn’t
> handle it well. A clean umount / mount cycle worked fine, but if you
> unexpectedly disconnected the device all hell broke loose and there was no
> way to recover.
> 
> I did it this way because, way back when, there were issues dynamically
> destroying SCSI hosts. The people who worked on those other layers found it
> much, much easier to fix that problem than try to make it possible to
> recover from an unexpected disconnect.
> 
> Honestly, I’m not even sure where you would need to begin to make this
> work. It would require pretty radical changes is the block I/O layers to
> differentiate different failure modes, keep a lot more data around after
> certain types of failures, allow for specifying which devices this new
> policy (which is assuming reconnected devices really haven’t been altered)
> applies to, etc — it’s a big lift.

Provided you don't mind giving up after 30 seconds (the default SCSI 
timeout), you wouldn't need to change the block or other layers.  All 
you would have to do is avoid reporting a command failure if the reason 
for the failure is disconnection, wait for the device to reappear, and 
then retry the command.  (Yes, there would be a few extra complications 
but that's the basic idea.)  As far as the SCSI or block layers are 
concerned, it would look like the I/O succeeded but took an unusually 
long time to complete.

Alan Stern

  parent reply	other threads:[~2022-08-21 19:03 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-21 11:17 USB disk disconnect problems James Dutton
2022-08-21 14:47 ` Alan Stern
2022-08-21 16:36   ` James Dutton
2022-08-21 16:40     ` James Dutton
2022-08-21 18:11       ` Alan Stern
     [not found]   ` <CAA6KcBC2wEc78fgrMLBfbyEinR3rVUY6z8HeUbE=wtv0c4BP2Q@mail.gmail.com>
2022-08-21 19:03     ` Alan Stern [this message]
2022-08-21 20:03   ` Matthew Dharm
2022-08-21 20:59     ` James Dutton
2022-08-21 21:26       ` Matthew Dharm
2022-08-21 22:56         ` James Dutton
2022-08-22 10:03           ` Oliver Neukum
2022-08-22 10:18       ` Oliver Neukum
2022-10-03 18:04 ` James Dutton
2022-10-03 18:17   ` Alan Stern
2022-10-03 20:21     ` James Dutton

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=YwKBj94XtgU70crx@rowland.harvard.edu \
    --to=stern@rowland.harvard.edu \
    --cc=james.dutton@gmail.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=mdharm-usb@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