Linux USB
 help / color / mirror / Atom feed
From: Alan Stern <stern@rowland.harvard.edu>
To: James Dutton <james.dutton@gmail.com>
Cc: "linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>
Subject: Re: USB disk disconnect problems
Date: Sun, 21 Aug 2022 10:47:00 -0400	[thread overview]
Message-ID: <YwJFZNUob3BtEM2h@rowland.harvard.edu> (raw)
In-Reply-To: <CAAMvbhFJ+jdFPh5dMV+_jjYUYYgWhCpv5E43Bh=Eoo6su80cUA@mail.gmail.com>

On Sun, Aug 21, 2022 at 12:17:30PM +0100, James Dutton wrote:
> Hi,
> 
> Say I have mounted a usb disk.
> I then disconnect the usb device
> Linux complains about failed writes etc.
> I then plug the usb device back in
> Linux still complains about failed writes, and does not recover.
> 
> How do I get Linux to recognise the reinserted usb disk and carry on as normal?

As far as I know, there's only way way to do it: Go into system suspend 
before disconnecting the USB drive, and plug the drive back in before 
waking the system up.

> 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.

The resume procedure makes this assumption, if it finds that something 
has been disconnected and reconnected.

> The reason being, I have a system that boots from a USB disk.
> Due to interference, the USB device disconnects for a second or two
> and then comes back, but Linux does not see it and I have to reboot
> Linux to recover. So, in this situation I wish Linux to be able to
> recover immediately, without needing a reboot.

There is no way to do this.  For example, consider all those failed 
writes that you get error messages about.  Once they have failed, the 
system does not try to remember them in case there's a possibility of 
trying them again later.  They're just lost.

Similarly with failed reads.  When a program tries to read something 
from a disk and the read fails, the program generally does not wait for 
a while and then retry the read, to see if the disk will magically start 
working again.

> The physical USB device removal then reinserting reproduces the
> problem I am seeing, so I thought it would be a good example to get
> working, if we could.
> 
> Can anyone give me any pointers as to where to start with fixing this?

Sorry I can't be of any more help.

Alan Stern

  reply	other threads:[~2022-08-21 14:47 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 [this message]
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
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=YwJFZNUob3BtEM2h@rowland.harvard.edu \
    --to=stern@rowland.harvard.edu \
    --cc=james.dutton@gmail.com \
    --cc=linux-usb@vger.kernel.org \
    /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