* [PATCH] MMC block removable flag @ 2004-12-30 2:14 Pierre Ossman 2004-12-30 9:54 ` Russell King 0 siblings, 1 reply; 9+ messages in thread From: Pierre Ossman @ 2004-12-30 2:14 UTC (permalink / raw) To: LKML, Russell King [-- Attachment #1: Type: text/plain, Size: 132 bytes --] A MMC card is a highly removable device. This patch makes the block layer part of the MMC layer set the removable flag. -- Pierre [-- Attachment #2: mmc-removable.patch --] [-- Type: text/x-patch, Size: 499 bytes --] Index: linux-wbsd/drivers/mmc/mmc_block.c =================================================================== --- linux-wbsd/drivers/mmc/mmc_block.c (revision 99) +++ linux-wbsd/drivers/mmc/mmc_block.c (revision 100) @@ -384,6 +384,7 @@ md->disk->private_data = md; md->disk->queue = md->queue.queue; md->disk->driverfs_dev = &card->dev; + md->disk->flags |= GENHD_FL_REMOVABLE; sprintf(md->disk->disk_name, "mmcblk%d", devidx); sprintf(md->disk->devfs_name, "mmc/blk%d", devidx); ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] MMC block removable flag 2004-12-30 2:14 [PATCH] MMC block removable flag Pierre Ossman @ 2004-12-30 9:54 ` Russell King 2004-12-30 15:56 ` Pierre Ossman 0 siblings, 1 reply; 9+ messages in thread From: Russell King @ 2004-12-30 9:54 UTC (permalink / raw) To: Pierre Ossman; +Cc: LKML On Thu, Dec 30, 2004 at 03:14:07AM +0100, Pierre Ossman wrote: > A MMC card is a highly removable device. This patch makes the block > layer part of the MMC layer set the removable flag. I have this patch also floating around, but I've decided it isn't needed. I believe this flag is to indicate that we have removable media for a block device rather than to indicate that the block device can be removed. However, when we insert and remove a MMC card, we create and destroy the block device itself. Therefore, as far as the block layer is concerned, the device itself is being inserted and removed, so telling the block layer that the media is removable is just silly - you can't separate the flash media from the on-board MMC controller. (Note: any block device can be removed - you just rmmod the module supplying the block device driver, but this doesn't mean we mark all block devices with GENHD_FL_REMOVABLE.) -- Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of: 2.6 PCMCIA - http://pcmcia.arm.linux.org.uk/ 2.6 Serial core ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] MMC block removable flag 2004-12-30 9:54 ` Russell King @ 2004-12-30 15:56 ` Pierre Ossman 2005-01-07 12:39 ` Russell King 0 siblings, 1 reply; 9+ messages in thread From: Pierre Ossman @ 2004-12-30 15:56 UTC (permalink / raw) To: Russell King; +Cc: LKML Russell King wrote: >On Thu, Dec 30, 2004 at 03:14:07AM +0100, Pierre Ossman wrote: > > >>A MMC card is a highly removable device. This patch makes the block >>layer part of the MMC layer set the removable flag. >> >> > >I have this patch also floating around, but I've decided it isn't needed. >I believe this flag is to indicate that we have removable media for a >block device rather than to indicate that the block device can be removed. > >However, when we insert and remove a MMC card, we create and destroy the >block device itself. Therefore, as far as the block layer is concerned, >the device itself is being inserted and removed, so telling the block >layer that the media is removable is just silly - you can't separate the >flash media from the on-board MMC controller. > >(Note: any block device can be removed - you just rmmod the module >supplying the block device driver, but this doesn't mean we mark all >block devices with GENHD_FL_REMOVABLE.) > > > I suspect that the removable flag might be used in different GUI:s to figure out with block devices should be presented to the user in a nice way. It's usually just the removable devices that need some form of special handling. So even though, as you point out, the entire device disappears it might be useful from a user interface perspective to have this hint set. From what I've found this flag doesn't seem to change any handling inside the kernel, just how the device should be perceived. Rgds Pierre ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] MMC block removable flag 2004-12-30 15:56 ` Pierre Ossman @ 2005-01-07 12:39 ` Russell King 2005-01-07 14:00 ` Andries Brouwer 0 siblings, 1 reply; 9+ messages in thread From: Russell King @ 2005-01-07 12:39 UTC (permalink / raw) To: Pierre Ossman, Al Viro, Jens Axboe; +Cc: LKML On Thu, Dec 30, 2004 at 04:56:45PM +0100, Pierre Ossman wrote: > Russell King wrote: > >On Thu, Dec 30, 2004 at 03:14:07AM +0100, Pierre Ossman wrote: > >>A MMC card is a highly removable device. This patch makes the block > >>layer part of the MMC layer set the removable flag. > > > >I have this patch also floating around, but I've decided it isn't needed. > >I believe this flag is to indicate that we have removable media for a > >block device rather than to indicate that the block device can be removed. > > > >However, when we insert and remove a MMC card, we create and destroy the > >block device itself. Therefore, as far as the block layer is concerned, > >the device itself is being inserted and removed, so telling the block > >layer that the media is removable is just silly - you can't separate the > >flash media from the on-board MMC controller. > > > >(Note: any block device can be removed - you just rmmod the module > >supplying the block device driver, but this doesn't mean we mark all > >block devices with GENHD_FL_REMOVABLE.) > > I suspect that the removable flag might be used in different GUI:s to > figure out with block devices should be presented to the user in a nice > way. It's usually just the removable devices that need some form of > special handling. So even though, as you point out, the entire device > disappears it might be useful from a user interface perspective to have > this hint set. From what I've found this flag doesn't seem to change any > handling inside the kernel, just how the device should be perceived. Can anyone comment on the purpose of this (GENHD_FL_REMOVABLE) flag? Al? Jens? -- Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of: 2.6 PCMCIA - http://pcmcia.arm.linux.org.uk/ 2.6 Serial core ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] MMC block removable flag 2005-01-07 12:39 ` Russell King @ 2005-01-07 14:00 ` Andries Brouwer 2005-01-08 11:09 ` Russell King 0 siblings, 1 reply; 9+ messages in thread From: Andries Brouwer @ 2005-01-07 14:00 UTC (permalink / raw) To: Pierre Ossman, Al Viro, Jens Axboe, LKML On Fri, Jan 07, 2005 at 12:39:47PM +0000, Russell King wrote: > On Thu, Dec 30, 2004 at 04:56:45PM +0100, Pierre Ossman wrote: > > Russell King wrote: > > >On Thu, Dec 30, 2004 at 03:14:07AM +0100, Pierre Ossman wrote: > > >>A MMC card is a highly removable device. This patch makes the block > > >>layer part of the MMC layer set the removable flag. > > > > > >I have this patch also floating around, but I've decided it isn't needed. > > >I believe this flag is to indicate that we have removable media for a > > >block device rather than to indicate that the block device can be removed. > > > > > >However, when we insert and remove a MMC card, we create and destroy the > > >block device itself. Therefore, as far as the block layer is concerned, > > >the device itself is being inserted and removed, so telling the block > > >layer that the media is removable is just silly - you can't separate the > > >flash media from the on-board MMC controller. > > > > > >(Note: any block device can be removed - you just rmmod the module > > >supplying the block device driver, but this doesn't mean we mark all > > >block devices with GENHD_FL_REMOVABLE.) > > > > I suspect that the removable flag might be used in different GUI:s to > > figure out with block devices should be presented to the user in a nice > > way. It's usually just the removable devices that need some form of > > special handling. So even though, as you point out, the entire device > > disappears it might be useful from a user interface perspective to have > > this hint set. From what I've found this flag doesn't seem to change any > > handling inside the kernel, just how the device should be perceived. > > Can anyone comment on the purpose of this (GENHD_FL_REMOVABLE) flag? > Al? Jens? GENHD_FL_REMOVABLE is set by a number of drivers (floppy, CDROM, ...). It is used in two places: (1) to fill the file /sys/block/*/removable (2) in genhd to suppress listing a nonpartitioned removable device in /proc/partitions. In other words, it is for user space only, precisely as Pierre Ossman said. Andries ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] MMC block removable flag 2005-01-07 14:00 ` Andries Brouwer @ 2005-01-08 11:09 ` Russell King 2005-01-08 12:05 ` Christoph Hellwig 2005-01-08 13:07 ` Andries Brouwer 0 siblings, 2 replies; 9+ messages in thread From: Russell King @ 2005-01-08 11:09 UTC (permalink / raw) To: Andries Brouwer; +Cc: Pierre Ossman, Al Viro, Jens Axboe, LKML On Fri, Jan 07, 2005 at 03:00:35PM +0100, Andries Brouwer wrote: > On Fri, Jan 07, 2005 at 12:39:47PM +0000, Russell King wrote: > > Can anyone comment on the purpose of this (GENHD_FL_REMOVABLE) flag? > > Al? Jens? > > GENHD_FL_REMOVABLE is set by a number of drivers (floppy, CDROM, ...). > It is used in two places: > (1) to fill the file /sys/block/*/removable > (2) in genhd to suppress listing a nonpartitioned removable device > in /proc/partitions. > > In other words, it is for user space only, precisely as Pierre Ossman said. Your point 2 isn't user space though. Also, it's buggy. Consider a SCSI PCMCIA card with SCSI disks attached. When you eject that card, your SCSI disks disappear, yet they aren't marked as removable. If user space is relying on /sys/block/*/removable to tell it if things may go away, then user space is buggy. Maybe it's for devices which may be present (eg, floppy driver), but which have removable media (eg, floppy disk), rather than removable devices? -- Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of: 2.6 PCMCIA - http://pcmcia.arm.linux.org.uk/ 2.6 Serial core ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] MMC block removable flag 2005-01-08 11:09 ` Russell King @ 2005-01-08 12:05 ` Christoph Hellwig 2005-01-08 12:45 ` Russell King 2005-01-08 13:07 ` Andries Brouwer 1 sibling, 1 reply; 9+ messages in thread From: Christoph Hellwig @ 2005-01-08 12:05 UTC (permalink / raw) To: Andries Brouwer, Pierre Ossman, Al Viro, Jens Axboe, LKML On Sat, Jan 08, 2005 at 11:09:57AM +0000, Russell King wrote: > Your point 2 isn't user space though. > > Also, it's buggy. Consider a SCSI PCMCIA card with SCSI disks attached. > When you eject that card, your SCSI disks disappear, yet they aren't > marked as removable. If user space is relying on /sys/block/*/removable > to tell it if things may go away, then user space is buggy. It means removable media. The actual device can disappear for just about any driver these days, considering pci hotplug or PCMCIA or usb or.. > Maybe it's for devices which may be present (eg, floppy driver), but > which have removable media (eg, floppy disk), rather than removable > devices? Yes. Else there would be very little driver that don't set the flag. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] MMC block removable flag 2005-01-08 12:05 ` Christoph Hellwig @ 2005-01-08 12:45 ` Russell King 0 siblings, 0 replies; 9+ messages in thread From: Russell King @ 2005-01-08 12:45 UTC (permalink / raw) To: Christoph Hellwig, Andries Brouwer, Pierre Ossman, Al Viro, Jens Axboe, LKML On Sat, Jan 08, 2005 at 12:05:17PM +0000, Christoph Hellwig wrote: > On Sat, Jan 08, 2005 at 11:09:57AM +0000, Russell King wrote: > > Your point 2 isn't user space though. > > > > Also, it's buggy. Consider a SCSI PCMCIA card with SCSI disks attached. > > When you eject that card, your SCSI disks disappear, yet they aren't > > marked as removable. If user space is relying on /sys/block/*/removable > > to tell it if things may go away, then user space is buggy. > > It means removable media. The actual device can disappear for just about > any driver these days, considering pci hotplug or PCMCIA or usb or.. > > > Maybe it's for devices which may be present (eg, floppy driver), but > > which have removable media (eg, floppy disk), rather than removable > > devices? > > Yes. Else there would be very little driver that don't set the flag. Ok. So the requirement is: (a) removable media with permanent block devices should set this flag. (b) removable block devices with permanent media should not set this flag. MMC is definitely case (b) - the block device is created and destroyed when the card is inserted and removed, since the block device corresponds to the controller on the card rather than the MMC host adapter. The media is permanently attached to the on-board controller. Therefore, it would be incorrect for the MMC block device driver to set the "removable" flag. I guess we now find out how many user applications incorrectly interpret this flag as meaning "this device may be user removable". Maybe this needs documenting in Documentation/block so that everyone knows what this flag is supposed to represent ? -- Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of: 2.6 PCMCIA - http://pcmcia.arm.linux.org.uk/ 2.6 Serial core ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] MMC block removable flag 2005-01-08 11:09 ` Russell King 2005-01-08 12:05 ` Christoph Hellwig @ 2005-01-08 13:07 ` Andries Brouwer 1 sibling, 0 replies; 9+ messages in thread From: Andries Brouwer @ 2005-01-08 13:07 UTC (permalink / raw) To: Andries Brouwer, Pierre Ossman, Al Viro, Jens Axboe, LKML On Sat, Jan 08, 2005 at 11:09:57AM +0000, Russell King wrote: > On Fri, Jan 07, 2005 at 03:00:35PM +0100, Andries Brouwer wrote: > > On Fri, Jan 07, 2005 at 12:39:47PM +0000, Russell King wrote: > > > Can anyone comment on the purpose of this (GENHD_FL_REMOVABLE) flag? > > > Al? Jens? > > > > GENHD_FL_REMOVABLE is set by a number of drivers (floppy, CDROM, ...). > > It is used in two places: > > (1) to fill the file /sys/block/*/removable > > (2) in genhd to suppress listing a nonpartitioned removable device > > in /proc/partitions. > > > > In other words, it is for user space only, precisely as Pierre Ossman said. > > Your point 2 isn't user space though. ?? (1) Is about filling /sys/... and (2) about filling /proc/... Both only have info for user space. The kernel does not react to this flag. > Also, it's buggy. Consider a SCSI PCMCIA card with SCSI disks attached. > When you eject that card, your SCSI disks disappear, yet they aren't > marked as removable. If user space is relying on /sys/block/*/removable > to tell it if things may go away, then user space is buggy. I think user space is pragmatic rather than correct. When undesirable things happen someone will complain, and the problem will be corrected somehow. The distinction removable / non-removable is too primitive, there are many variations involving chains of devices. > Maybe it's for devices which may be present (eg, floppy driver), but > which have removable media (eg, floppy disk), rather than removable > devices? I told you what it does. But you ask what it is intended for. Then you must go to the person who first introduced it. I guess that might have been Richard Gooch. The flag came in in patch-2.3.46 with devfs. If it is was set, devfs would set DEVFS_FL_REMOVABLE. +- Added DEVFS_FL_REMOVABLE flag + +- Check for disc change when listing directories with + removable media devices One has code like + if (flags & DEVFS_FL_REMOVABLE) + { + de->u.fcb.removable = TRUE; + ++de->parent->u.dir.num_removable; + } and +static void scan_dir_for_removable (struct devfs_entry *dir) +/* [SUMMARY] Scan a directory for removable media devices and check media. + <dir> The directory. + [RETURNS] Nothing. +*/ +{ + struct devfs_entry *de; + + if (dir->u.dir.num_removable < 1) return; + for (de = dir->u.dir.first; de != NULL; de = de->next) + { + if (!de->registered) continue; + if ( !S_ISBLK (de->mode) ) continue; + if (!de->u.fcb.removable) continue; + check_disc_changed (de); + } +} /* End Function scan_dir_for_removable */ So here you have it. It is a devfs thing and could have been removed when devfs was removed. However, today it is exported in sysfs, and one must worry about possible users in user space. Andries ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2005-01-08 13:07 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2004-12-30 2:14 [PATCH] MMC block removable flag Pierre Ossman 2004-12-30 9:54 ` Russell King 2004-12-30 15:56 ` Pierre Ossman 2005-01-07 12:39 ` Russell King 2005-01-07 14:00 ` Andries Brouwer 2005-01-08 11:09 ` Russell King 2005-01-08 12:05 ` Christoph Hellwig 2005-01-08 12:45 ` Russell King 2005-01-08 13:07 ` Andries Brouwer
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox