linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: bert hubert <ahu@ds9a.nl>
To: Greg KH <greg@kroah.com>
Cc: linux-hotplug-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org
Subject: [2.6.9-rc4] USB && mass-storage && disconnect broken semantics
Date: Mon, 11 Oct 2004 12:07:01 +0000	[thread overview]
Message-ID: <20041011120701.GA824@outpost.ds9a.nl> (raw)

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.

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.

What actually happens with 2.6.9-rc4 is this:

[plug in the memory stick]
usb 1-2: new high speed USB device using address 9
scsi7 : SCSI emulation for USB Mass Storage devices
  Vendor: M-Sys     Model: DiskOnKey         Rev: 4.20
  Type:   Direct-Access                      ANSI SCSI revision: 02
Attached scsi removable disk sda at scsi7, channel 0, id 0, lun 0
Attached scsi generic sg0 at scsi7, channel 0, id 0, lun 0,  type 0

Note that the numbers 7 and 9 increase which each unplug/replug event, even
when no mount was attempted. This may be a bad thing in and of itself.

Now we mount:

# mount /dev/sda1 /keychain
# grep /keychain /proc/mounts 
/dev/sda1 /keychain vfat rw,nodiratime,fmask\033,dmask\033 0 0

dmesg reports:
USB Mass Storage device found at 8
SCSI device sda: 499712 512-byte hdwr sectors (256 MB)
sda: Write Protect is off
sda: Mode Sense: 45 00 00 08
sda: assuming drive cache: write through
SCSI device sda: 499712 512-byte hdwr sectors (256 MB)
sda: Write Protect is off
sda: Mode Sense: 45 00 00 08
sda: assuming drive cache: write through
 sda: sda1

Note the duplication.

Now we unplug the memory stick:

usb 1-2: USB disconnect, address 9
# grep /keychain /proc/mounts 
/dev/sda1 /keychain vfat rw,nodiratime,fmask\033,dmask\033 0 0

# ls /keychain
# 

No errors reported by ls, dmesg is filled with:
scsi7 (0:0): rejecting I/O to dead device
FAT: Directory bread(block 517) failed
scsi7 (0:0): rejecting I/O to dead device
FAT: Directory bread(block 518) failed
scsi7 (0:0): rejecting I/O to dead device
FAT: Directory bread(block 519) failed
scsi7 (0:0): rejecting I/O to dead device
FAT: Directory bread(block 520) failed

We can unmount /keychain, this reports in dmesg:
SCSI error: host 7 id 0 lun 0 return code = 4000000
	Sense class 0, sense error 0, extended sense 0

# grep /keychain /proc/mounts
#

On reinsert, we can mount again:
usb 1-2: new high speed USB device using address 10
scsi8 : SCSI emulation for USB Mass Storage devices
  Vendor: M-Sys     Model: DiskOnKey         Rev: 4.20
  Type:   Direct-Access                      ANSI SCSI revision: 02
Attached scsi removable disk sda at scsi8, channel 0, id 0, lun 0
Attached scsi generic sg0 at scsi8, channel 0, id 0, lun 0,  type 0

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.

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.

Thanks.

-- 
http://www.PowerDNS.com      Open source, database driven DNS Software 
http://lartc.org           Linux Advanced Routing & Traffic Control HOWTO


-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

             reply	other threads:[~2004-10-11 12:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-11 12:07 bert hubert [this message]
2004-10-11 15:37 ` [2.6.9-rc4] USB && mass-storage && disconnect broken semantics Kay Sievers
2004-10-11 16:07   ` David Brownell
2004-10-12  5:54   ` bert hubert
2004-10-12  8:22 ` James Bruce
2004-10-12 10:24   ` Oliver Neukum
2004-10-12 10:46     ` bert hubert
2004-10-13 19:01     ` Linas Vepstas

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=20041011120701.GA824@outpost.ds9a.nl \
    --to=ahu@ds9a.nl \
    --cc=greg@kroah.com \
    --cc=linux-hotplug-devel@lists.sourceforge.net \
    --cc=linux-kernel@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;
as well as URLs for NNTP newsgroup(s).