Bug 24602 - cd-rom polling/media detection broken with ide-cd
Summary: cd-rom polling/media detection broken with ide-cd
Status: RESOLVED WONTFIX
Alias: None
Product: udisks
Classification: Unclassified
Component: detection (show other bugs)
Version: unspecified
Hardware: Other All
: high blocker
Assignee: David Zeuthen (not reading bugmail)
QA Contact:
URL: http://bugs.debian.org/cgi-bin/bugrep...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-10-18 07:43 UTC by Michael Biebl
Modified: 2010-03-12 11:50 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
dk-disks dump after a fake change uevent (19.76 KB, text/plain)
2009-11-12 15:07 UTC, Michael Biebl
Details
add support for ide-cd cd-roms (11.52 KB, patch)
2009-11-17 15:00 UTC, Michael Biebl
Details | Splinter Review

Description Michael Biebl 2009-10-18 07:43:11 UTC
Hi,

please see the referenced bug report at [1].
From looking at the code, it seems dk-disk makes the assumption that only libata is used thus breaking systems which use ide-core/ide-cd.

This results in the cd-drive being unusable as it is constantly retracted when polled.


[1] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=550316
Comment 1 David Zeuthen (not reading bugmail) 2009-10-24 08:11:54 UTC
Yeah, this would be good to fix (although I wish that someone would nuke the non-libata drivers). So we should probably modify devkit-disks-poller.c so it sends "/dev/sdb,0 /dev/sr0,1" to the polling process (with the second element being whether it's a cdrom drive or not). Patch welcome.

FWIW, long-term I want devkit-disks-daemon to be a multi-threaded process (for many other reasons) and then the poller can just use the DevkitDisksDevice instance structure to figure how to poll the device. But that's long-term and not going to happen soon.
Comment 2 Michael Biebl 2009-11-12 14:04:52 UTC
(In reply to comment #1)
> Yeah, this would be good to fix (although I wish that someone would nuke the
> non-libata drivers). So we should probably modify devkit-disks-poller.c so it
> sends "/dev/sdb,0 /dev/sr0,1" to the polling process (with the second element
> being whether it's a cdrom drive or not). Patch welcome.

It's not as simple as that unfortunately.
currently, the poller does nothing else besides opening the device repeatedly.
With libata this generates a uevent when a media has been inserted (or removed).

This is not the case for ide-cd. open(ing) the device with the correct set of flags (O_RDONLY | O_NONBLOCK | O_EXCL) will *not* generate a uevent if a media is present.
hal used ioctl's to poke the device afair. We could do similar in the poller process, but then we would need to communicate the results back to the main process. David suggested to fake/synthesize a uevent instead or alternatively fix the kernel/ide-cd.
Comment 3 David Zeuthen (not reading bugmail) 2009-11-12 14:08:58 UTC
(In reply to comment #2)
> (In reply to comment #1)
> > Yeah, this would be good to fix (although I wish that someone would nuke the
> > non-libata drivers). So we should probably modify devkit-disks-poller.c so it
> > sends "/dev/sdb,0 /dev/sr0,1" to the polling process (with the second element
> > being whether it's a cdrom drive or not). Patch welcome.
> 
> It's not as simple as that unfortunately.
> currently, the poller does nothing else besides opening the device repeatedly.
> With libata this generates a uevent when a media has been inserted (or
> removed).
> 
> This is not the case for ide-cd. open(ing) the device with the correct set of
> flags (O_RDONLY | O_NONBLOCK | O_EXCL) will *not* generate a uevent if a media
> is present.
> hal used ioctl's to poke the device afair. We could do similar in the poller
> process, but then we would need to communicate the results back to the main
> process. David suggested to fake/synthesize a uevent instead or alternatively
> fix the kernel/ide-cd.

Kay, do you think it's feasible to fix the non-libata cdrom drivers? Apparently they don't generate any uevent on media change. I think that's a bug.
Comment 4 Michael Biebl 2009-11-12 15:07:01 UTC
(In reply to comment #2)
> process. David suggested to fake/synthesize a uevent instead or alternatively

Trying to fake a "change" uevent manually after inserting the media (echo "change" > /sys/class/block/hdc/uevent) makes dk-disks detect that there is a media present (a dump of dk-disks is attached)

The file system probing itself does not work yet.
The (Debian) udev rules contain:

# probe filesystem metadata of optical drives which have a media inserted
KERNEL=="sr*", ENV{ID_CDROM_MEDIA}=="?*", \
        ENV{ID_CDROM_MEDIA_SESSION_LAST_OFFSET}=="?*", \
        IMPORT{program}="/sbin/blkid -o udev -p -u noraid -O $env{ID_CDROM_MEDIA_SESSION_LAST_OFFSET} $tempnode"
# single-session CDs do not have ID_CDROM_MEDIA_SESSION_LAST_OFFSET
KERNEL=="sr*", ENV{ID_CDROM_MEDIA}=="?*", \
        ENV{ID_CDROM_MEDIA_SESSION_LAST_OFFSET}=="", \
        IMPORT{program}="/sbin/blkid -o udev -p -u noraid $tempnode"

i.e. they don't act on hd* devices (in my case hdc)
Comment 5 Michael Biebl 2009-11-12 15:07:43 UTC
Created attachment 31144 [details]
dk-disks dump after a fake change uevent
Comment 6 Kay Sievers 2009-11-12 17:32:18 UTC
(In reply to comment #3)

> Kay, do you think it's feasible to fix the non-libata cdrom drivers? Apparently
> they don't generate any uevent on media change. I think that's a bug.

I doubt we would be able to fix them. They are officially deprecated and in "let it die" mode:
  http://thread.gmane.org/gmane.linux.ide/43151

Distros really should just disable the old IDE stuff.
Comment 7 David Zeuthen (not reading bugmail) 2009-11-13 07:38:03 UTC
(In reply to comment #6)
> (In reply to comment #3)
> 
> > Kay, do you think it's feasible to fix the non-libata cdrom drivers? Apparently
> > they don't generate any uevent on media change. I think that's a bug.
> 
> I doubt we would be able to fix them. They are officially deprecated and in
> "let it die" mode:
>   http://thread.gmane.org/gmane.linux.ide/43151
> 
> Distros really should just disable the old IDE stuff.
> 

OK, thanks for information, Kay.

It might not be worth trying to fix things here. Maybe we just make a note in NEWS that this won't work with the old IDE drivers (and maybe we just unconditionally ignore any device matching "hd*" to be on the safe side).

Michael, Debian is switching completely to libata anyway, right?
Comment 8 Michael Biebl 2009-11-16 09:23:05 UTC
(In reply to comment #7)
> (In reply to comment #6)
> > (In reply to comment #3)
> > 
> > > Kay, do you think it's feasible to fix the non-libata cdrom drivers? Apparently
> > > they don't generate any uevent on media change. I think that's a bug.
> > 
> > I doubt we would be able to fix them. They are officially deprecated and in
> > "let it die" mode:
> >   http://thread.gmane.org/gmane.linux.ide/43151
> > 
> > Distros really should just disable the old IDE stuff.
> > 
> 
> OK, thanks for information, Kay.
> 
> It might not be worth trying to fix things here. Maybe we just make a note in
> NEWS that this won't work with the old IDE drivers (and maybe we just
> unconditionally ignore any device matching "hd*" to be on the safe side).
> 
> Michael, Debian is switching completely to libata anyway, right?
> 

It will be, but currently it still uses ide-cd. We also have the issue of partial upgrades (Debian usually tries to support using the kernel from distro-1). 

Good news is, I now have a patch which uses your fake uevent idea and it seems to work reasonably well. So I'll use that for the dk-disks package in Debian for now. If you are interested, I can post it here.
Comment 9 David Zeuthen (not reading bugmail) 2009-11-16 09:59:57 UTC
(In reply to comment #8)
> Good news is, I now have a patch which uses your fake uevent idea and it seems
> to work reasonably well. So I'll use that for the dk-disks package in Debian
> for now. If you are interested, I can post it here.

Sure, no harm in posting the patch - can't guarantee it goes into master though.

Thanks,
David
Comment 10 Michael Biebl 2009-11-17 15:00:59 UTC
Created attachment 31285 [details] [review]
add support for ide-cd cd-roms
Comment 11 David Zeuthen (not reading bugmail) 2010-03-12 06:41:05 UTC
AFAIK the upstream kernel dropped old IDE drivers recently. Either way, we really don't want to support the old IDE drivers so I'm closing this bug.
Comment 12 Michael Biebl 2010-03-12 11:50:48 UTC
(In reply to comment #11)
> AFAIK the upstream kernel dropped old IDE drivers recently. Either way, we
> really don't want to support the old IDE drivers so I'm closing this bug.

That is not correct as far as it goes for 2.6.34-rc1 afaics.
The old ide drivers are simply marked as deprecated, but still available.
So, it is still possible, that users compile their kernel using the old IDE subsystem (iirc there are still 1 or 2 drivers which are not ported yet).

That said, I'm fine with keeping this patch in Debian only.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.