USB/hal: USB open() broken? (USB CD burner underruns, USB HDD hard resets)
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 9 lines · Alan Cox
Ar Maw, 2006-06-20 am 11:05 +0200, ysgrifennodd Andreas Mohr:
Quoted 6 lines
But how would HAL safely determine whether a (IDE/USB) drive is busy? As my test app demonstrates (without HAL running), the *very first*
open()happening during an ongoing burning operation will kill it instantly, in the USB case.
Are there any options left for HAL at all? Still seems to strongly point towards a kernel issue so far.
Quoted 3 lines
In the IDE space
O_EXCLhas the needed semantics. At least it does on Fedora and I don't think thats a Fedora patch, not sure if this is the case for the USB side of things.
This does not work, since O_EXCL does not work:
http://lkml.org/lkml/2006/2/5/137
Instead, I'd (try to) use mandatory locking and prevent open() etc. from causing the bad commands to be sent.
Signature · 4 lines
Ich danke GMX dafür, die Verwendung meiner Adressen mittels per SPF verbreiteten Lügen zu sabotieren. http://david.woodhou.se/why-not-spf.html
Ar Mer, 2006-06-21 am 02:07 +0200, ysgrifennodd Bodo Eggert:
Quoted 2 lines
This does not work, since
O_EXCLdoes not work:
http://lkml.org/lkml/2006/2/5/137
It works fine. Its an advisory exclusive locking scheme which is precisely what is needed and precisely how some vendors implement their solution.
There are good reasons for not having absolute locks, one of which is that you might want to force a reset or a hot unplug of an interface knowing you'll lose the CD its burning (eg because your flight is about to leave)
Alan
Quoted 8 lines · Alan Cox
Ar Mer, 2006-06-21 am 02:07 +0200, ysgrifennodd Bodo Eggert:
Quoted 2 lines
This does not work, since
O_EXCLdoes not work:
http://lkml.org/lkml/2006/2/5/137It works fine. Its an advisory exclusive locking scheme which is precisely what is needed and precisely how some vendors implement their solution.
This will be as effective as "/var/lock/please-don't-touch-the-burner", and the lock is more portable ...
Quoted 4 lines
There are good reasons for not having absolute locks, one of which is that you might want to force a reset or a hot unplug of an interface knowing you'll lose the CD its burning (eg because your flight is about to leave)
Killing cdrecord should take care of that lock.
Hi,
Quoted 6 lines · Bodo Eggert
Quoted 5 lines · Alan Cox
Ar Mer, 2006-06-21 am 02:07 +0200, ysgrifennodd Bodo Eggert:
Quoted 2 lines
This does not work, since
O_EXCLdoes not work:
http://lkml.org/lkml/2006/2/5/137
Quoted 6 lines
Quoted 3 lines
It works fine. Its an advisory exclusive locking scheme which is precisely what is needed and precisely how some vendors implement their solution.
This will be as effective as "/var/lock/please-don't-touch-the-burner", and the lock is more portable ...
Indeed, until all(!) relevant apps specify the cooperative O_EXCL flag, there will always be some trouble left somewhere...
And of course don't even dare trying to do a simply shell cat on the raw I/O device during an ongoing burning operation, will you!?
Maybe it's better to (additionally?) go down the route of fixing up low-level communication weaknesses (since it's been semi-confirmed that it's an USB communication issue, see other thread part).
IMHO this is a severe user experience issue that shouldn't be fixed up ("covered", "hidden") by the O_EXCL thingy alone.
Andreas Mohr
Quoted 5 lines · Andreas Mohr
Maybe it's better to (additionally?) go down the route of fixing up low-level communication weaknesses (since it's been semi-confirmed that it's an USB communication issue, see other thread part).
IMHO this is a severe user experience issue that shouldn't be fixed up ("covered", "hidden") by theO_EXCLthingy alone.
It's not a USB issue; it's a matter of lack of coordination between the sg and sr drivers. Each is unaware of the actions of the other, even when they are speaking to the same device.
Alan Stern
Hi,
Quoted 11 lines · Alan Stern
Quoted 5 lines · Andreas Mohr
Maybe it's better to (additionally?) go down the route of fixing up low-level communication weaknesses (since it's been semi-confirmed that it's an USB communication issue, see other thread part).
IMHO this is a severe user experience issue that shouldn't be fixed up ("covered", "hidden") by theO_EXCLthingy alone.It's not a USB issue; it's a matter of lack of coordination between the sg and sr drivers. Each is unaware of the actions of the other, even when they are speaking to the same device.
Right, I could have expressed it much better before, sorry.
Found the relevant code:sd.c sd_open()
if (!sdkp->openers++ && sdev->removable) {
if (scsi_block_when_processing_errors(sdev))
scsi_set_medium_removal(sdev, SCSI_REMOVAL_PREVENT);
}And the obvious question would be whether the sdkp->openers++ thingy could somehow be extended to enclose all hardware device users so that e.g. sr.c wouldn't send ALLOW_MEDIUM_REMOVAL on a device already locked by e.g. the sd.c driver.
Difficult question, though, since the group of drivers possible to use with a certain device is not a static set:
it could be via
- sr.c
- sd.c
- IDE (in the case of ATA devices mapped via ide-scsi)
- ???
Is it possible to have such a per-*hardware*-device instance in the kernel to keep track of various things such as number of device openers? I'll do some investigation myself, too...
Thanks!
Andreas Mohr
Quoted 6 lines · Andreas Mohr
Quoted 3 lines
It's not a USB issue; it's a matter of lack of coordination between the sg and sr drivers. Each is unaware of the actions of the other, even when they are speaking to the same device.
Right, I could have expressed it much better before, sorry.
Quoted 7 lines
Found the relevant code:
sd.csd_open()if (!sdkp->openers++ && sdev->removable) { if (scsi_block_when_processing_errors(sdev)) scsi_set_medium_removal(sdev, SCSI_REMOVAL_PREVENT); }
Um, this isn't the relevant code. You're interested in sr.c, not sd.c. Furthermore, the actual ALLOW MEDIUM REMOVAL command is caused by code in drivers/cdrom/cdrom.c:cdrom_release(). This needs to be coordinated (the cdi->use_count variable) with the sg driver.
Quoted 12 lines
And the obvious question would be whether the sdkp->openers++ thingy could somehow be extended to enclose all hardware device users so that e.g.
sr.cwouldn't sendALLOW_MEDIUM_REMOVALon a device already locked by e.g. thesd.cdriver.
Difficult question, though, since the group of drivers possible to use with a certain device is not a static set:
it could be via
-sr.c
-sd.c
- IDE (in the case of ATA devices mapped via ide-scsi)
- ???
Quoted 3 lines
Is it possible to have such a per-*hardware*-device instance in the kernel to keep track of various things such as number of device openers? I'll do some investigation myself, too...
Look at include/scsi/scsi_device.h. There's plenty of opportunity for adding an additional counter.
Alan Stern
On Wed, 21 Jun 2006, Andreas Mohr wrote:
[...]
Quoted 11 lines
And the obvious question would be whether the sdkp->openers++ thingy could somehow be extended to enclose all hardware device users so that e.g.
sr.cwouldn't sendALLOW_MEDIUM_REMOVALon a device already locked by e.g. thesd.cdriver.
Difficult question, though, since the group of drivers possible to use with a certain device is not a static set:
it could be via
-sr.c
-sd.c
- IDE (in the case of ATA devices mapped via ide-scsi)
Quoted 3 lines
Is it possible to have such a per-*hardware*-device instance in the kernel to keep track of various things such as number of device openers? I'll do some investigation myself, too...
The sg part should be implemented by each SCSI device, reducing the current sg device to a mostly empty shell. Then you can prevent that empty shell from binding to devices having more specific drivers.
Signature · 2 lines
Top 100 things you don't want the sysadmin to say: 30. And what does it mean 'rm: .o: No such file or directory'?
Ar Mer, 2006-06-21 am 15:02 -0400, ysgrifennodd Alan Stern:
Quoted 3 lines
It's not a USB issue; it's a matter of lack of coordination between the sg and sr drivers. Each is unaware of the actions of the other, even when they are speaking to the same device.
Thats a relevant issue but sg is irrelevant for cd burning except with various ancient software setups. Probably sg/sr should share the O_EXCL locking but its not part of the cd burning stuff for modern setups.
Alan