Bug 154326

Summary: [zypp] 'please insert CDn' popup does not unmount/release media
Product: [openSUSE] SUSE Linux 10.1 Reporter: Klaus Kämpf <kkaempf>
Component: HotplugAssignee: Ihno Krumreich <ihno>
Status: RESOLVED FIXED QA Contact: E-mail List <qa-bugs>
Severity: Critical    
Priority: P5 - None CC: aj, felix, hi-du, kontakt, mengjie.yu, mt, suse-beta, TiloLutz
Version: Beta 6   
Target Milestone: ---   
Hardware: Other   
OS: Other   
Whiteboard:
Found By: Other Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: shortened log
shortened log
YaST2 log

Description Klaus Kämpf 2006-03-01 11:22:46 UTC
When requesting a file from a specific media, MediaCD::MediaCD() is called (again?, it was called before already, see bug154322)

When the media verifier detects the wrong CD, it does not release the previously attached media. See attached log (shortened)

See bug154322 for the full log.
Comment 1 Klaus Kämpf 2006-03-01 11:23:17 UTC
Created attachment 70763 [details]
shortened log
Comment 2 Klaus Kämpf 2006-03-01 11:25:18 UTC
Created attachment 70769 [details]
shortened log

Argh, the first attachment had lines cut off.
Comment 3 Klaus Kämpf 2006-03-01 11:28:41 UTC
I don't see a release() call in the Callbacks::requestMedia() function of pkg-bindings. Is this called anywhere ?
Comment 4 Stanislav Visnovsky 2006-03-01 11:38:48 UTC
Yes, see SourceImpl.cc SourceImpl::provideFile()
Comment 5 Klaus Kämpf 2006-03-01 11:41:58 UTC
Good spotting, there is the bug.
It calls the report->requestMedia() callback directly without(!) releasing the media.
Comment 6 Klaus Kämpf 2006-03-01 11:42:48 UTC
            else if ( user == media::MediaChangeReport::RETRY  ||
            user == media::MediaChangeReport::CHANGE_URL )
            {
              // retry
              DBG << "Going to release and attach again" << endl;

              media_mgr.release (_media, false);
              media_mgr.attach( _media );

              break;

Thats wrong. The "media_mgr.release (_media, false);" must be called before(!) the callback.
Comment 7 Klaus Kämpf 2006-03-01 11:43:33 UTC
            else if ( user == media::MediaChangeReport::EJECT )
            {
              DBG << "Eject: try to release" << endl;

              media_mgr.release (_media, true);
              // FIXME: this will not work, probably

Well, indeed this works.
Marius, will this still work if the media is already released ??
Comment 8 Klaus Kämpf 2006-03-01 11:49:06 UTC
From looking at the source, I'm pretty sure the eject does work even though the media is unmounted.
Comment 9 Marius Tomaschewski 2006-03-01 12:13:49 UTC
If the media is already released, a release(_media, true) will work.
If will eject all drives that are not attached.
Comment 10 Klaus Kämpf 2006-03-01 12:16:00 UTC
So this one fixes the "eject button does not work" bug:
Index: SourceImpl.cc
===================================================================
--- SourceImpl.cc       (revision 2169)
+++ SourceImpl.cc       (working copy)
@@ -125,10 +125,15 @@
        catch ( Exception & excp )
         {
            media::MediaChangeReport::Action user;
+
          do {
+
+           DBG << "Media couldn't release file, releasing." << endl;
+           media_mgr.release (_media, false);
+
            user  = checkonly ? media::MediaChangeReport::ABORT :
              report->requestMedia (
-               source_factory.createFrom(this),
+               source_factory.createFrom( this ),
                media_nr,
                media::MediaChangeReport::WRONG, // FIXME: proper error
                excp.msg()
@@ -152,9 +157,8 @@
            user == media::MediaChangeReport::CHANGE_URL )
            {
              // retry
-             DBG << "Going to release and attach again" << endl;
+             DBG << "Going to attach again" << endl;

-             media_mgr.release (_media, false);
              media_mgr.attach( _media );

              break;
Comment 11 Klaus Kämpf 2006-03-01 12:16:50 UTC
This one is fixed
Comment 13 Klaus Kämpf 2006-03-01 14:16:14 UTC
*** Bug 152260 has been marked as a duplicate of this bug. ***
Comment 14 Stanislav Visnovsky 2006-03-01 14:46:03 UTC
*** Bug 151786 has been marked as a duplicate of this bug. ***
Comment 15 Christian Boltz 2006-03-12 15:00:46 UTC
*** Bug 157419 has been marked as a duplicate of this bug. ***
Comment 16 Christian Boltz 2006-03-12 19:35:46 UTC
*** Bug 157483 has been marked as a duplicate of this bug. ***
Comment 17 Forgotten User jstLBAkSfa 2006-03-14 09:45:12 UTC
SLES10 Beta7 still has the same behaviour - when installing software with yast I cannot insert another CD without calling eject in a terminal window. Per the above the fix wasn't applied for beta6, but obviously it wasn't applied for beta7 either. 
This cripples the yast sw_single module, as you can't really use it to install software with dependencies spread over several CDs. 
Will the fix be in beta8?
Comment 18 Stanislav Visnovsky 2006-03-14 12:51:42 UTC
Seems like you are pointing to a running system. Please:

1) remove /var/log/YaST2/y2log*
2) reproduce the bug
3) attach the resulting logs.
Comment 19 Forgotten User jstLBAkSfa 2006-03-14 13:05:15 UTC
Created attachment 72764 [details]
YaST2 log

You are right, it's the running system (but had this during installation as well).
Created and attached the logs as described above.
Comment 20 Tilo Lutz 2006-03-19 10:51:05 UTC
This bug is still in 10.1 beta 8.

I use an external usb cdrom drive, sr0
When yast asks for the next disc
the media is still mounted.

Mount when inserting a new media before
pressing ok to accept the new media in yast:

notebook:/home/tilo/Modem # mount
/dev/hda1 on / type reiserfs (rw,acl,user_xattr)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
udev on /dev type tmpfs (rw)
devpts on /dev/pts type devpts (rw,mode=0620,gid=5)
securityfs on /sys/kernel/security type securityfs (rw)
/dev/sr0 on /media/disk-1 type iso9660 (ro,nosuid,nodev,noatime,uid=1000,utf8)


When yast asks for the next disc, the old one ist still mounted:
notebook:/home/tilo/Modem # mount
/dev/hda1 on / type reiserfs (rw,acl,user_xattr)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
udev on /dev type tmpfs (rw)
devpts on /dev/pts type devpts (rw,mode=0620,gid=5)
securityfs on /sys/kernel/security type securityfs (rw)
/dev/sr0 on /media/disk-1 type iso9660 (ro,nosuid,nodev,noatime,uid=1000,utf8)
/dev/sr0 on /var/adm/mount/AP_0x00000005 type iso9660 (ro)

I isn't possible to release the media. The eject button in yast isn't working.
When I press the eject button at the drive I get an kde error:
kio_media_mounthelper "authorization refused"

I have to unmount /var/adm/mount/AP_0x000000005 before I can change
the media.

After unmounting I was able to change the media.
Comment 22 Marius Tomaschewski 2006-03-21 10:24:48 UTC
The problem is not the /var/adm/mount/AP_0x000000005 (or AP_0x0000000d
in the log) mountpoint, but the additional one: /media/disk-1

YaST2/ZYPP umounts its own mount on AP_*, but the eject request fails:
  MediaCD.cc(openTray):173 Eject /dev/sr0 failed (Input/output error)
because the media is still mounted on /media/disk-1.

In earlier versions it was not a problem (eject failed because of other
reasons), because the subfs mounter used fake-mounts only. Now, it realy
mounts the media on /media/disk-1.

I've added a fix, that trys to umount the other (user) mountpoints as
well if eject was requested.
Comment 23 Stanislav Visnovsky 2006-03-21 11:26:10 UTC
we need to avoid the automatic mounting somehow.
Comment 24 Marius Tomaschewski 2006-03-21 14:25:59 UTC
With the above changes (zypp SVN revision 2585), it works
fine, although it is very ugly to umount foreign media.

Perhaps somebody has an better idea how to solve it finally.

Beta8 RPMs containing this fix/workaround will be avaliable
at http://www.suse.de/~mt/zypp/ (as soon as it is mirrored)
for testing.
Note, that installing them, may break other (yast2) pieces,
because there was some symbol changes in the libraries...
Comment 26 Ihno Krumreich 2006-03-23 13:00:30 UTC
Does bug 153241 solves your problem?
Comment 27 Marius Tomaschewski 2006-03-23 16:01:15 UTC
OK, this allows to disable the automounter. Not a problem
to add the calls to zypp.

I would propose to disable the automounter and limit my hack
to try to umount the automounter mountpoint if it is there.

If the user has mountet it manually, eject will still fail.

If the eject fails, it will be currently not reported to the
above layers (complains in log only). I would like to throw
an Busy/NotEjected-exception, but Stano does no like it :-)

This means, the problem remains in cases, where the media is
busy.
We have to decide how exactly to handle it. Stano / Klaus?
Comment 28 Marius Tomaschewski 2006-03-27 16:04:14 UTC
*** Bug 159263 has been marked as a duplicate of this bug. ***
Comment 29 Klaus Kämpf 2006-04-04 14:17:09 UTC
Looks fixed in Beta9, no further reports.