Re: [2.6.9-rc4] USB && mass-storage && disconnect broken semantics

From: Kay Sievers
Date: Mon Oct 11 2004 - 10:45:45 EST


On Mon, Oct 11, 2004 at 02:07:01PM +0200, bert hubert wrote:
> Ok,
>
> This is about stupid users (including me) unplugging USB devices whilst
> still mounted, and expecting sane semantics.
>
> This has generally not been the 'Unix' or even 'Linux' way, but people
> expect it to work. I also see no clear automated and robust solution from
> userspace. "Don't do that then" is a pretty weak answer, especially since we
> want to work on the desktop.
>
> The expected behaviour is that on forceably unplugging an USB memory stick,
> the created SCSI device should vanish, along with the mounts based on it.

That is clearly bejond the scope of the kernel or hotplug. This policy
belongs to some other device management software. We are currently working on
HAL as one example, to make that happen.

> When the user plugs in the device again, people expect to see it get the
> first available name, and be available for remount, possible automated.
...
> Sometimes however, sda appears to be still 'occupied', and higher names are
> used.
>
> Now - the perhaps intended behaviour where the user can replug the USB
> device when it was disconnected by accident also does not work. When we do
> this, things get really out of whack, /dev/sda1 has now become invalid.

Forget about the kernel device names, these are "cookies" to access the
device and have no other meaning. Never rely on that longer as your
device session lasts! You may use a udev rule to create a stable name for
your device based on some unique device property and that will work.
Btw: With HAL we even don't care about the /dev-name, all volumes are
recognized by uuid or fslabel.

> Unmounting and unplugging and replugging saves us.
>
> Greg, others, I hope you agree this needs work. I hope we have the
> infrastructure to umount based on USB disconnect events, or, alternatively,
> will support 'replugging' which at least does part of what people expect.

Yes, we need to make the unplug of mounted devices more safe, especially
with sync mount, but don't expect the kernel or hotplug to do anything
like that. It's up to some policy software higher in the stack.

Thanks,
Kay
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/