Bug 390204

Summary: yast2 doesn't wait long enough after media change
Product: [openSUSE] openSUSE 11.0 Reporter: Tejun Heo <teheo>
Component: KernelAssignee: Matthias Koenig <mkoenig>
Status: RESOLVED FIXED QA Contact: Jiri Srain <jsrain>
Severity: Normal    
Priority: P5 - None CC: coolo, jreidinger, jsuchome, lslezak
Version: Beta 2   
Target Milestone: ---   
Hardware: Other   
OS: Other   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: y2logs.tar.gz

Description Tejun Heo 2008-05-14 11:41:34 UTC
When installing packages from DVD or CD and the media is not in the tray, yast prompts for the media.  After putting in the media, I have to tell it to retry two or three times before it finally recognizes the media.  It gets worse if the "automatically eject" feature is turned on.  When I press retry, it goes out to check media presence for a bit and thinks there's no media and eject it, so unless I press retry after quite a while, I'm never gonna get the media recognized.

I think the sense data is different while the media is getting recognized from when there's no media in the tray.  It seems we need to improve media presence polling logic.
Comment 1 Ladislav Slezák 2008-05-15 13:17:00 UTC
This is something for the Media backend or HAL, DBUS..?? Jano?
Comment 2 Josef Reidinger 2008-05-15 15:20:15 UTC
Can you please provide log?
Comment 3 Tejun Heo 2008-05-16 04:00:48 UTC
Is save_y2logs afterward enough?
Comment 4 Josef Reidinger 2008-05-16 06:15:48 UTC
maybe, if logged message doesn't been overwritten by latter commands. (it depends on allowed size of your logs). So attach it and if it doesn't contain it I say.
Comment 5 Tejun Heo 2008-05-17 01:52:50 UTC
Created attachment 216146 [details]
y2logs.tar.gz

Here's the y2log.  If the log doesn't have what's needed, please lemme know.  I'll try to reproduce the problem.
Comment 6 Josef Reidinger 2008-05-20 08:28:35 UTC
I looks like bug is not in libzypp, because mount is called correctly, but immediately return medium not found (which is not expected if CD is allready inserted).
Reassign to mount maintainer.
Comment 7 Tejun Heo 2008-05-23 00:55:31 UTC
Waiting for drive readiness has never been mount's responsibility.  There's related issue being discussed in bug #390934.  I'll cc you there.  Thanks.
Comment 8 Matthias Koenig 2008-05-27 13:25:50 UTC
Yes, mount returns medium not found because the syscall mount(2) returns ENOMEDIUM.
It is not the responsibility of the mount program to wait for a medium it does not even know about.
Comment 9 Matthias Koenig 2008-05-30 15:43:42 UTC
*** Bug 395130 has been marked as a duplicate of this bug. ***
Comment 10 Jan Kupec 2008-05-30 16:00:08 UTC
The bug is far from invalid, and it is a regression from 10.3 where the media were properly read even if it took some more time. If this is not responsibility of mount, then it is responsibility of whatever that handles the syscall and reassigned, not closed as invalid.

Who should take over?
Comment 11 Matthias Koenig 2008-06-02 08:51:12 UTC
Ok, you are right. This has worked on 10.3.
The difference seems to be that on 10.3 the open call for the CD device blocks until the device could be read.
While on 11.0 the open call itself also returns ENOMEDIUM:
open("/dev/sr0", O_RDONLY)              = -1 ENOMEDIUM (No medium found)

So this has changed on the kernel side, not sure if this was intentional.
Comment 13 Tejun Heo 2008-06-09 03:57:40 UTC
Okay, the difference is from the addition of cdrom_get_media_event() call to both sr_drive_status() and ide_cdrom_drive_status().  Previously, the cdrom driver can't differentiate between tray closed w/ no media and tray open and always returned tray open, which triggers close and retry in the open logic which probably have delayed things enough to get the media recognized.

Now the cdrom driver can discern between tray closed w/o media and device not ready for other reasons and returns -ENOMEDIUM on the former.  This is all good and dandy but the problem seems that some drives report no media right after the tray is closed but it hasn't properly detected the media yet.

It seems the only way to work around the problem is via sensible retries (e.g. try three times 5 secs apart) and I don't think we can add that type of retry logic into cdrom open path.  Please note that the previous logic wasn't water proof.  Some drives can take longer to recognize the media is there and could have failed the in-kernel retry too.  Also, reading the media can take quite some time and during that period the drive reports media present but device not ready.  The driver will retry the command (e.g. READ TOC for open) five times but all of them can fail w/ EMEDIUMTYPE.

I think adding userland retries is necessary, at least for now.
Comment 14 Tejun Heo 2008-06-09 04:49:04 UTC
Please take a look at the following bug which deals with the same problem in live cd.  Maybe the workaround can be shared?

https://bugzilla.novell.com/show_bug.cgi?id=390934
Comment 15 Matthias Koenig 2008-06-09 12:52:19 UTC
Ok, thanks for explanation. I will add some retry logic to userland mount.
Comment 16 Matthias Koenig 2008-06-25 15:42:01 UTC
Fixed in STABLE.