CD eject but not unmount when using drive button and CD is in fstab

Bug #476654 reported by Edgar Cherkasov on 2009-11-06
154
This bug affects 26 people
Affects Status Importance Assigned to Milestone
udisks
Fix Released
Medium
devicekit-disks (Ubuntu)
Undecided
Unassigned
Karmic
Medium
Martin Pitt
Lucid
Undecided
Unassigned
udisks (Ubuntu)
Medium
Martin Pitt
Karmic
Undecided
Unassigned
Lucid
Medium
Martin Pitt

Bug Description

Binary package hint: devicekit-disks

1) Insert disk
2) eject disk using drive button
3) icon stay on the desktop, files show in nautilus, etc.

From messages:
....
Nov 6 19:25:29 edgar-desktop kernel: [ 2775.318724] VFS: busy inodes on changed media or resized disk sr0
Nov 6 19:25:29 edgar-desktop kernel: [ 2775.331479] VFS: busy inodes on changed media or resized disk sr0

these messages shows until such time as not to insert a disc or not forcibly unmount

ProblemType: Bug
Architecture: amd64
Date: Fri Nov 6 19:28:59 2009
DistroRelease: Ubuntu 9.10
InstallationMedia: Ubuntu 9.10 "Karmic Koala" - Release amd64 (20091027)
MachineType: System manufacturer P5QL PRO
NonfreeKernelModules: nvidia
Package: devicekit-disks 007-2ubuntu3
ProcCmdLine: BOOT_IMAGE=/boot/vmlinuz-2.6.31-14-generic root=UUID=b5c3322e-637f-4df0-a47b-ccebb1372d6c ro quiet splash
ProcEnviron:
 LANG=ru_RU.UTF-8
 SHELL=/bin/bash
ProcVersionSignature: Ubuntu 2.6.31-14.48-generic
SourcePackage: devicekit-disks
Uname: Linux 2.6.31-14-generic x86_64
dmi.bios.date: 07/01/2009
dmi.bios.vendor: American Megatrends Inc.
dmi.bios.version: 1004
dmi.board.asset.tag: To Be Filled By O.E.M.
dmi.board.name: P5QL PRO
dmi.board.vendor: ASUSTeK Computer INC.
dmi.board.version: Rev 1.xx
dmi.chassis.asset.tag: Asset-1234567890
dmi.chassis.type: 3
dmi.chassis.vendor: Chassis Manufacture
dmi.chassis.version: Chassis Version
dmi.modalias: dmi:bvnAmericanMegatrendsInc.:bvr1004:bd07/01/2009:svnSystemmanufacturer:pnP5QLPRO:pvrSystemVersion:rvnASUSTeKComputerINC.:rnP5QLPRO:rvrRev1.xx:cvnChassisManufacture:ct3:cvrChassisVersion:
dmi.product.name: P5QL PRO
dmi.product.version: System Version
dmi.sys.vendor: System manufacturer

Edgar Cherkasov (edgar2705) wrote :
Martin Pitt (pitti) on 2009-11-10
Changed in devicekit-disks (Ubuntu):
status: New → Triaged
importance: Undecided → Medium
Andrew Ivanov (aa.ivanov) wrote :

So far I have observed the described behaviour with several different disks on my laptop.

Strangely enough when today I decided to get a better look at what's actually happening I was unable to reproduce it. Instead of ejecting without unmounting, the eject button on the drive now does nothing unless the disk is unmounted first.

The 'eject' command is working as expected - unmounting and ejecting.

No change in configuration was made since the last time the misbehaviour was observed.

Please advise if any further information is necessary.

Edgar Cherkasov (edgar2705) wrote :

How to reproduce:
1) insert disk in drive (nautilus show window with files and folders)
2) push hardware button on DVD drive (
3) files shown in nautilus
3a) type "mount" in terminal. Result for me: /dev/sr0 on /media/cdrom0 type iso9660 (ro,nosuid,nodev,utf8,user=edgar)

P.S.
eject works fine

Martin Pitt (pitti) on 2010-02-15
affects: devicekit-disks (Ubuntu) → udisks (Ubuntu)
Martin Pitt (pitti) on 2010-03-11
Changed in udisks (Ubuntu Lucid):
status: Triaged → In Progress
assignee: nobody → Martin Pitt (pitti)
Bryan Wu (cooloney) wrote :

Martin,

Thanks a lot. Is that possible to back port this fixing into devicekit-disks for karmic, since we are using that?

-Bryan

Bryan Wu [2010-03-11 10:54 -0000]:
> Thanks a lot. Is that possible to back port this fixing into devicekit-
> disks for karmic, since we are using that?

In principle it should be; the difficulty depends on how big the patch
will be (I haven't looked into the code at all yet; we just discussed
what he root cause is and how/where it should be fixed).

Martin
--
Martin Pitt | http://www.piware.de
Ubuntu Developer (www.ubuntu.com) | Debian Developer (www.debian.org)

Martin Pitt (pitti) on 2010-03-12
Changed in udisks (Ubuntu Lucid):
status: In Progress → Fix Committed
status: Fix Committed → In Progress

Hm, so I can't actually reproduce this. I tried this for ten times, and it always works. udisks says:

**** CHANGING /sys/devices/pci0000:00/0000:00:1d.7/usb1/1-8/1-8.4/1-8.4:1.0/host2/target2:0:0/2:0:0:0/block/sr0
**** UPDATING /sys/devices/pci0000:00/0000:00:1d.7/usb1/1-8/1-8.4/1-8.4:1.0/host2/target2:0:0/2:0:0:0/block/sr0
**** EMITTING CHANGED for /sys/devices/pci0000:00/0000:00:1d.7/usb1/1-8/1-8.4/1-8.4:1.0/host2/target2:0:0/2:0:0:0/block/sr0
**** NOTE: Force unmounting device /dev/sr0
**** EMITTING JOB-CHANGED for /sys/devices/pci0000:00/0000:00:1d.7/usb1/1-8/1-8.4/1-8.4:1.0/host2/target2:0:0/2:0:0:0/block/sr0
helper(pid 18840): launched job umount on /dev/sr0
[...]
helper(pid 18840): completed with exit code 0
**** NOTE: Successfully force unmounted device /dev/sr0

and the mount is gone. Originally I thought that udisks would just lack a code path for not handling forced unmounts of devices where just the media disappears (like CD-ROMs) instead of the entire device (like USB sticks).

Does this work with USB sticks for you? I. e. do you get mounts cleaned up if you just yank them out without proper unmounting/ejecting? (Please be careful, this could cause data corruption; please at least run "sync" before you do that).

To get some better logs from your system, please do the following:

 * Ensure that there is no CD-ROM inside, and no stale mount.

 * Open a Terminal and do

    udevadm monitor -e --udev > /tmp/udev.log 2>&1 &
    sudo /usr/lib/udisks/udisks-daemon --replace > /tmp/udisks.log 2>&1

 * Insert a CD, and wait until it gets automounted (You'll get the icon on the desktop)

  * Eject it using the drive button, wait a couple of seconds, and ensure that you get a stale mount.

Press Control-C, then run "fg", press Control-C again (to stop both monitors), and attach /tmp/udev.log and /tmp/udisks.log here.

Thanks!

Changed in udisks (Ubuntu Lucid):
status: In Progress → Incomplete
David Tombs (dgtombs) wrote :

I can't test this on Lucid since I have to use a Live CD, but here are the corresponding logs from Karmic if they're helpful.

David Tombs (dgtombs) wrote :
David Tombs (dgtombs) wrote :

Oh, and yanking USB sticks unmounts as it should.

When pressing the CD drive eject button while the CD is mounted, udisks normally force-unmounts the CD to avoid stale mounts:

**** CHANGING /sys/devices/pci0000:00/0000:00:1d.7/usb1/1-8/1-8.4/1-8.4:1.0/host2/target2:0:0/2:0:0:0/block/sr0
**** UPDATING /sys/devices/pci0000:00/0000:00:1d.7/usb1/1-8/1-8.4/1-8.4:1.0/host2/target2:0:0/2:0:0:0/block/sr0
**** EMITTING CHANGED for /sys/devices/pci0000:00/0000:00:1d.7/usb1/1-8/1-8.4/1-8.4:1.0/host2/target2:0:0/2:0:0:0/block/sr0
**** NOTE: Force unmounting device /dev/sr0
**** EMITTING JOB-CHANGED for /sys/devices/pci0000:00/0000:00:1d.7/usb1/1-8/1-8.4/1-8.4:1.0/host2/target2:0:0/2:0:0:0/block/sr0
helper(pid 18840): launched job umount on /dev/sr0
[...]
helper(pid 18840): completed with exit code 0
**** NOTE: Successfully force unmounted device /dev/sr0

However, this does not work if the CD is in /etc/fstab, which is still a fairly common setup from older Linux distro installations:

**** CHANGED /sys/devices/pci0000:00/0000:00:1d.7/usb1/1-8/1-8.4/1-8.4:1.0/host2/target2:0:0/2:0:0:0/block/sr0
helper(pid 3113): completed with exit code 0
**** UPDATING /sys/devices/pci0000:00/0000:00:1d.7/usb1/1-8/1-8.4/1-8.4:1.0/host2/target2:0:0/2:0:0:0/block/sr0
**** EMITTING CHANGED for /sys/devices/pci0000:00/0000:00:1d.7/usb1/1-8/1-8.4/1-8.4:1.0/host2/target2:0:0/2:0:0:0/block/sr0
**** Unlocking CD-ROM door for /dev/sr0
**** EMITTING JOB-CHANGED for /sys/devices/pci0000:00/0000:00:1d.7/usb1/1-8/1-8.4/1-8.4:1.0/host2/target2:0:0/2:0:0:0/block/sr0

The problem is in force_removal():

| if (device->priv->device_is_mounted && device->priv->device_mount_paths->len > 0)

This condition is fine, udisks properly tracks mounts in fstab.

| {
| gboolean remove_dir_on_unmount;
|
| if (mount_file_has_device (device->priv->device_file, NULL, &remove_dir_on_unmount))

This is the culprit. The mount won't be in /var/lib/udisks/mtab, thus force_unmount() is never called.

| {
| g_print ("**** NOTE: Force unmounting device %s\n", |device->priv->device_file);
| force_unmount (device, callback, user_data);

So there are two options:

 - Don't care about mount_file_has_device() and always clean up stale mounts. This is certainly a valid approach, and I don't see the value of keeping around stale mounts, but there might be cases, or simply a definition, that udisks shouldn't interfere with mounts at all that it didn't mount in the first place.

 - Add alternative check if fstab has the device.

I'd go with the second approach for now.

Created an attachment (id=34038)
check for fstab drives in force_unmount

With this patch, udisks properly cleans up stale mounts for CD-ROMs if they are in /etc/fstab.

David, does that look okay to you?

David,

thanks. So your log shows that udev gets the change event just fine, and detects that the CD does not have any media any more. So from the kernel/udev side, karmic is fine. dk-disks also gets the change event, but doesn't react to it with a forced unmount.

One important thing that I see from the log is that you apparently have the CD drive in /etc/fstab, which I don't. I'll try this on my system on lucid.

@all: You can test this on lucid by using the Startup Disk Creator to put the iso onto an USB stick and boot from that, so that you have the CD drive free to test this bug.

Martin Pitt (pitti) wrote :

Ah, that was it. I added the CD drive to /etc/fstab, and now I can reproduce this. This is still a fairly common setup, so we need to support it still.

summary: - CD eject but not unmount when using drive button
+ CD eject but not unmount when using drive button and CD is in fstab
Changed in udisks (Ubuntu Lucid):
status: Incomplete → In Progress
Martin Pitt (pitti) wrote :

I sent a proposed patch to the upstream bug, I'm fairly sure it's okay. Waiting for David's comment (since there's an alternative approach of how this could be fixed). I'll commit this upstream once I get his ack.

Martin Pitt (pitti) wrote :

I backported the patch to devicekit-disks and uploaded a test package (version 007-2ubuntu4pitti1) to my PPA:

  https://launchpad.net/~pitti/+archive/ppa

(I don't have any other karmic packages in that PPA, so merely adding it and upgrading your system is safe.)

Testing and feedback appreciated!

Changed in udisks (Ubuntu Karmic):
status: New → Invalid
Changed in devicekit-disks (Ubuntu Lucid):
status: New → Invalid
Changed in devicekit-disks (Ubuntu Karmic):
assignee: nobody → Martin Pitt (pitti)
importance: Undecided → Medium
status: New → In Progress
Changed in udisks:
status: Unknown → In Progress
Bryan Wu (cooloney) wrote :

Martin,

Thanks a lot. I will test you PPA on those problem machine this week.

-Bryan

David Tombs (dgtombs) wrote :

Hi Martin, your PPA version seems to fix it for me. Thank you!

PS: I don't think I ever modified my fstab, and in fact both of my Ubuntu boxes have a line for the CD. Are you sure that's not the default configuration?

(In reply to comment #2)
> Created an attachment (id=34038) [details]
> check for fstab drives in force_unmount
>
> With this patch, udisks properly cleans up stale mounts for CD-ROMs if they are
> in /etc/fstab.
>
> David, does that look okay to you?
>

Actually, I don't think this is correct (specifically: we only want to force-unmount the device if it was actually mounted by udisks itself)... but it's probably good enough for now.

For the record, bug 24279 is the bug for tracking the more general problem.

Also this is actually a dupe of bug 24708 (please read it including the link to the gnome bug) but I'm closing the other one since there is more information here.

*** Bug 24708 has been marked as a duplicate of this bug. ***

(In reply to comment #3)
> Actually, I don't think this is correct (specifically: we only want to
> force-unmount the device if it was actually mounted by udisks itself)

Hm, we could write a record into /var/lib/udisks/mtab if udisks mounted something in fstab? That might indeed be a better fix, since right now we don't know whether it was the user or udisks once udisks-daemon is done with the mount.

(In reply to comment #3)
>... but it's probably good enough for now.

I pushed the fix to git, but I'll keep this bug open for discussing how to fix it in a better way (like tracking fstab mounts by udisks in /var/lib/udisks/mtab?)

cliftonlai (cliftonlai) wrote :

It does really work and it looks fine, Thanks

Martin Pitt (pitti) wrote :

I committed the fix upstream.

I still need testing feedback for the karmic update.

Changed in udisks (Ubuntu Lucid):
status: In Progress → Fix Committed
David Tombs (dgtombs) wrote :

Interestingly, I think the patch might have fixed bug #462885 on my Karmic box as well.

David Tombs [2010-03-15 5:19 -0000]:
> PS: I don't think I ever modified my fstab, and in fact both of my
> Ubuntu boxes have a line for the CD. Are you sure that's not the default
> configuration?

It was until karmic or so.

Martin

--
Martin Pitt | http://www.piware.de
Ubuntu Developer (www.ubuntu.com) | Debian Developer (www.debian.org)

Martin Pitt (pitti) wrote :

Thanks for testing! I also committed that patch upstream now.

Subscribing ubuntu-sru then.

IMPACT: Using the eject button on CD-ROM drives leaves a stale /media/cdrom mount around if the CD drive is in /etc/fstab (as the Ubuntu installer set up until jaunty or karmic).

FIX:
 - upstream: http://cgit.freedesktop.org/udisks/commit/?id=3e14a2ff841b477f269a4e95ee19a11bceb2a354
 - lucid: uploaded to unapproved queue, will go in after beta-1
 - karmic: patch logically applies, but needs to be ported for different code formatting and devicekit-disks vs. udisks names

REGRESSION POTENTIAL:
 - This patch applies to any media in /etc/fstab, not just to CD-ROMs. So if there previously was an assumption that mounts would stay around even with the device media disappearing underneath, this assumption would now be broken. This is fairly academic, though, IMHO.
 - The patch just adds another OR condition, thus does not affect behaviour if CD drives (or drives in general) are not in /etc/fstab.

TEST CASE:
 - Add CD-ROM to /etc/fstab:

   /dev/sr0 /cdrom udf,iso9660 defaults,user 0 0

 - Insert CD, let it automount

 - Press eject button on the drive
    * on karmic: /cdrom mount stays around
    * with fix: /cdrom mount disappears (gets umount -l /cdrom from devicekit-disks)

Uploaded package to karmic-proposed, I need another ubuntu-sru member to review.

George Dhoore (georgiepoo) wrote :

Your patch for Karmic works wonderfully for me. Thank you very much for all the effort you put into this.

George Dhoore (georgiepoo) wrote :

I should also add that like Mr. Tombs above in comment #18 that this bug also fixes https://bugs.launchpad.net/bugs/462885 for me.

John Dong (jdong) wrote :

The patch makes sense for a SRU. Great to already hear reports that the patch addresses the issue!

ACK from -sru :)

Accepted devicekit-disks into karmic-proposed, the package will build now and be available in a few hours. Please test and give feedback here. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you in advance!

Changed in devicekit-disks (Ubuntu Karmic):
status: In Progress → Fix Committed
tags: added: verification-needed
David Tombs (dgtombs) wrote :

Installed the -proposed version and everything seems to be working great! The behavior is so "expected" now that I can hardly believe it. :) Thank you!

$ apt-cache policy devicekit-disks
devicekit-disks:
  Installed: 007-2ubuntu5
  Candidate: 007-2ubuntu5
  Version table:
 *** 007-2ubuntu5 0
        400 http://ubuntu.media.mit.edu karmic-proposed/main Packages
        100 /var/lib/dpkg/status
     007-2ubuntu4pitti1 0
        500 http://ppa.launchpad.net karmic/main Packages
     007-2ubuntu4 0
        500 http://ubuntu.media.mit.edu karmic-updates/main Packages
     007-2ubuntu3 0
        500 http://ubuntu.media.mit.edu karmic/main Packages

Martin Pitt (pitti) on 2010-03-19
tags: added: verification-done
removed: verification-needed
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package udisks - 1.0.0-0ubuntu1

---------------
udisks (1.0.0-0ubuntu1) lucid; urgency=low

  [ Martin Pitt ]
  * debian/control: Prefer building against current libparted0-dev. Add
    alternative libparted-dev build dependency as well.
  * debian/rules: Build a PO template during package build, to have an up to
    date one for translators. (LP: #538320)
  * Drop debian/local/ubuntu.pkla again: This will be provided by a new
    policykit-desktop-permissions package.

  [ Michael Biebl ]
  * New upstream release.
    - Clean up stale mounts from devices in /etc/fstab, too. (LP: #476654)
    - Fix recognition of unpartitioned VFAT drives, which were previously
      misdetected as MBR. (LP: #536670)
    - Use lseek64() instead of lseek() in job-drive-benchmark.c, to also work
      with large devices. (LP: #526524)
  * Refresh patches.
 -- Martin Pitt <email address hidden> Tue, 16 Mar 2010 14:57:23 +0100

Changed in udisks (Ubuntu Lucid):
status: Fix Committed → Fix Released
Dmitriy Kodanev (dkodanev) wrote :

Excuse me, but I don't now really know, is the issue I have related to this branch of bugs... So, let me explain please.

I have had a problem with my CD-ROM since I've installed Karmic. I hadn't it in Jaunty. Well, I've reported about the bug (in dublicate of this one (https://bugs.launchpad.net/ubuntu/+source/devicekit-disks/+bug/491552), but anyway...)

I've just installed new package from proposed. What can I say? It works - but not at all. Earlier (in Karmic before the patch) nothing happened at all. Now, if I insert a DVD with a film, I see a new icon on the desktop and TOTEM begin to play. And then I stop Totem, eject a disc, load the same DVD again and see the icon on the desktop and Totem plays again... BUT when I push the button on the DVD drive, NOTHING is happened! Just the same - if you want to eject your disc, you have to select in context menu - no way else!

If you wish to know, I'had this experience on my Acer Extensa 4220. If you need some extra information, let me know. I'll give it to you. Because I really want this annoying bug to be corrected.

David Tombs (dgtombs) wrote :

Hi timroll,

It sounds like you're also experiencing bug 397734.

Launchpad Janitor (janitor) wrote :

This bug was fixed in the package devicekit-disks - 007-2ubuntu5

---------------
devicekit-disks (007-2ubuntu5) karmic-proposed; urgency=low

  * Add 10-force-unmount-fstab.patch: force_removal() previously only checked
    for entries in our own mtab. This caused forced unmounts for drives in
    /etc/fstab not to work. Now check for drives in /etc/fstab as well.
    (LP: #476654)
 -- Martin Pitt <email address hidden> Sun, 14 Mar 2010 21:06:50 +0100

Changed in devicekit-disks (Ubuntu Karmic):
status: Fix Committed → Fix Released

I use Ubuntu Lucid Lynx 10.04 32-bit and have udisks 1.0.1 installed. I just experienced this bug that prevented me from burning a DVD-ROM with Brasero.

David Tombs (dgtombs) wrote :

R33D3M33R: You're probably experiencing a different bug. Please file a new one with "ubuntu-bug udisks".

Changed in udisks:
importance: Unknown → Medium
Vancouverite (sethgilchrist) wrote :

I am having this same issue in Maverick. Should this fix have gone through to 10.10?

udisks 1.0.1+git20100614-3

Thanks for the help.

David Tombs (dgtombs) wrote :

Vancouverite: You're probably experiencing a different bug. Please file a new one with "ubuntu-bug udisks".

Leo (llenchikk) wrote :

David: I have the same issue too. Bug description corresponds with my actions. For what it should be a new bug.
My system is Ubuntu 10.10 64bit.

David Tombs (dgtombs) wrote :

Leo, et al: The reason is that this bug was /fixed/ for the vast majority of people that had the problem. Therefore, if you're still experiencing similar symptoms, it has a different root cause and should be a different bug. Bug reports are ideally separated per root cause, not per description.

Changed in udisks:
importance: Medium → Unknown
Changed in udisks:
importance: Unknown → Medium
Dan Jared (danjaredg) wrote :

this bug is present on 11.10 Oneiric too

Clint Byrum (clint-fewbar) wrote :

Hi Dan. This bug was already confirmed as being fixed, so if you are seeing it again in 11.10, we need to track that as a new bug tagged with 'regression-release'.

Please run 'ubuntu-bug udisks' on your affected system to file it. You may want to reference this bug # in your report, and also comment back here so affected users find the new report.

I am also having this bug on both my desktop and laptop

With udisks 2.0 this is no longer a problem I think. Closing.

Changed in udisks:
status: In Progress → Fix Released

This is also an issue in 13.04. If I use icon on the launcher to eject, everything works properly. If I run umount /dev/sr0 and then use the hardware button everything is fine, but just pressing the button alone does not unmount the disk (in my case a DVD). Since it doesn't look like there has been much activity here, if I don't see a response in the next few days, I'll file a new bug to make sure it can be taken care of before 13.04 officially launches.

David Tombs (dgtombs) wrote :

Please do file a new bug as this one has been fixed. You are probably experiencing a different underlying issue. Thanks.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.