All of lore.kernel.org
 help / color / mirror / Atom feed
* USB forceful removal
@ 2014-07-08 18:43 AYAN KUMAR HALDER
  2014-07-08 18:55 ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: AYAN KUMAR HALDER @ 2014-07-08 18:43 UTC (permalink / raw)
  To: kernelnewbies

Hi All,

When a usb mass-storage is attached for the first time, it gets a
device (/dev/sda).

When it is mounted and the device is manually removed and then when it
is attached again, it gets a different name ie /dev/sdb.

This is because earlier the mass-storage device was removed (manually)
when it was mounted, so scsi_disk_release() did not get called as the
device (sda) had a reference count > 1.

So, if my understanding is correct, I would like to know if the above
mentioned behaviour is a bug or a limitation of the kernel?

Regards,
Ayan Kumar Halder

^ permalink raw reply	[flat|nested] 5+ messages in thread

* USB forceful removal
  2014-07-08 18:43 USB forceful removal AYAN KUMAR HALDER
@ 2014-07-08 18:55 ` Greg KH
  2014-07-08 22:17   ` Greg Freemyer
  0 siblings, 1 reply; 5+ messages in thread
From: Greg KH @ 2014-07-08 18:55 UTC (permalink / raw)
  To: kernelnewbies

On Wed, Jul 09, 2014 at 12:13:28AM +0530, AYAN KUMAR HALDER wrote:
> Hi All,
> 
> When a usb mass-storage is attached for the first time, it gets a
> device (/dev/sda).
> 
> When it is mounted and the device is manually removed and then when it
> is attached again, it gets a different name ie /dev/sdb.

Really?  Not on my system, what kernel are you using?

> This is because earlier the mass-storage device was removed (manually)
> when it was mounted, so scsi_disk_release() did not get called as the
> device (sda) had a reference count > 1.

It should have...

> So, if my understanding is correct, I would like to know if the above
> mentioned behaviour is a bug or a limitation of the kernel?

What is wrong with the device node showing back up as /dev/sdb?  You
shouldn't be relying on a device node name for doing anything "real"
anyway, that's what /dev/disk/ is there for, the persistent links are
designed for you to mount with.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 5+ messages in thread

* USB forceful removal
  2014-07-08 18:55 ` Greg KH
@ 2014-07-08 22:17   ` Greg Freemyer
  2014-07-08 22:33     ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: Greg Freemyer @ 2014-07-08 22:17 UTC (permalink / raw)
  To: kernelnewbies

On Tue, Jul 8, 2014 at 2:55 PM, Greg KH <greg@kroah.com> wrote:
> On Wed, Jul 09, 2014 at 12:13:28AM +0530, AYAN KUMAR HALDER wrote:
>> Hi All,
>>
>> When a usb mass-storage is attached for the first time, it gets a
>> device (/dev/sda).
>>
>> When it is mounted and the device is manually removed and then when it
>> is attached again, it gets a different name ie /dev/sdb.
>
> Really?  Not on my system, what kernel are you using?

Greg, I just tried the experiment and had the above described behavior:

- Connect external USB-3 drive, drive assigned /dev/sdb
- mount -r /dev/sdb1 /mnt
- pull the usb connector
- wait 30 seconds, and reconnect
- drive assigned /dev/sdc

I'm running openSUSE with the distro kernel 3.11.6-4-desktop.

I then added "umount /mnt" before pulling the usb connector and
/dev/sdc was re-used on reconnect.

<snip>

> thanks,
>
> greg k-h

the other greg

^ permalink raw reply	[flat|nested] 5+ messages in thread

* USB forceful removal
  2014-07-08 22:17   ` Greg Freemyer
@ 2014-07-08 22:33     ` Greg KH
  2014-07-09 19:06       ` AYAN KUMAR HALDER
  0 siblings, 1 reply; 5+ messages in thread
From: Greg KH @ 2014-07-08 22:33 UTC (permalink / raw)
  To: kernelnewbies

On Tue, Jul 08, 2014 at 06:17:56PM -0400, Greg Freemyer wrote:
> On Tue, Jul 8, 2014 at 2:55 PM, Greg KH <greg@kroah.com> wrote:
> > On Wed, Jul 09, 2014 at 12:13:28AM +0530, AYAN KUMAR HALDER wrote:
> >> Hi All,
> >>
> >> When a usb mass-storage is attached for the first time, it gets a
> >> device (/dev/sda).
> >>
> >> When it is mounted and the device is manually removed and then when it
> >> is attached again, it gets a different name ie /dev/sdb.
> >
> > Really?  Not on my system, what kernel are you using?
> 
> Greg, I just tried the experiment and had the above described behavior:
> 
> - Connect external USB-3 drive, drive assigned /dev/sdb
> - mount -r /dev/sdb1 /mnt
> - pull the usb connector
> - wait 30 seconds, and reconnect
> - drive assigned /dev/sdc
> 
> I'm running openSUSE with the distro kernel 3.11.6-4-desktop.
> 
> I then added "umount /mnt" before pulling the usb connector and
> /dev/sdc was re-used on reconnect.

If you use a "desktop automount system", you don't have to worry about
this as you don't have to mount the filesystem, it will happen
automagically at /var/run/media/ and then go away when the device is
unplugged.

But yes, you are right, if you explicitly mount the filesystem, the sd
name will stay around, which is the correct kernel functionality.  Same
thing happens for lots of other types of dynamic devices (ttys, char
devices, etc.)

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 5+ messages in thread

* USB forceful removal
  2014-07-08 22:33     ` Greg KH
@ 2014-07-09 19:06       ` AYAN KUMAR HALDER
  0 siblings, 0 replies; 5+ messages in thread
From: AYAN KUMAR HALDER @ 2014-07-09 19:06 UTC (permalink / raw)
  To: kernelnewbies

> But yes, you are right, if you explicitly mount the filesystem, the sd
> name will stay around, which is the correct kernel functionality.  Same
> thing happens for lots of other types of dynamic devices (ttys, char
> devices, etc.)
>
> thanks,
>
> greg k-h

Hi,

Thanks for your response. The situation that I had described is
analogous to what I have faced.
I am trying to test the linux power management framework (for
hibernation) on a ARM based custom SoC which has a usb host
controller.
I attach an external usb mass-storage device(hard disk), mount it
(/dev/sda) and then hibernate the system.
On resuming I see that the usb device gets detached, the controller re
probes for the device, and the device gets re-attached as /dev/sdb.

I see that in this situation too the scsi_disk_release do not get
called because of the reference count.
So I was wondering if it is expected behaviour of kernel or not.

Regards,
Ayan Kumar Halder

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-07-09 19:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-08 18:43 USB forceful removal AYAN KUMAR HALDER
2014-07-08 18:55 ` Greg KH
2014-07-08 22:17   ` Greg Freemyer
2014-07-08 22:33     ` Greg KH
2014-07-09 19:06       ` AYAN KUMAR HALDER

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.