On Sun, 21 Aug 2022 at 21:03, Matthew Dharm <mdharm-usb@xxxxxxxxxxxxxxxxxx> wrote: > > (Re-sending, as the first one got blocked by the list for having an HTML part). > > On Sun, Aug 21, 2022 at 7:47 AM Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> 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. > > 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. > Are there any situations where we should actually try to recover? What about: The OS has not needed to read/write to the disk in a while. The USB disk idles out and goes into a power save mode by itself. The OS then wishes to write something, but would need to go through some sort of wake up procedure first. I don't know if that is a state that is available for USB devices, but if it was, would it be fair to try and recover?