GNOME Bugzilla – Bug 774192
Says "You can now unplug" when only a partition is unmounted
Last modified: 2016-11-21 09:56:08 UTC
Connect an external hard drive with multiple partitions with file systems on them (e.g. /dev/sdb1 and sdb2). Several "Files" windows pop up, with all these volumes shown in the left hand bar, with an Eject button next to each. Click on one of these Eject buttons. The corresponding file system is properly unmounted. Plus, a desktop notification "You can now unplug [VolumeName]" is presented. This is incorrect, I clearly cannot unplug the disk as long as other partitions of it are mounted, and there's obviously no way I could unplug a partition without unplugging the entire disk. The notification with such wording should only be presented if it was the last file system of the given disk that I unmounted (ejected).
I hope you don't mind me setting Severity: critical. This is (as far as I know) the typical value for bugs that can cause data loss. In my opinion if the data loss is not directly caused by the program code, but rather by the program giving false information to the user and the user potentially following that instruction, it's no different at all. Nautilus _must not_ tell me it's safe to remove something when in fact it's not.
Thanks for your bug report. Hmm, this is a rather GVfs issue, however, I can't reproduce it with devices I have. Both partitions are unmounted if I click on the eject button, not only the one. Although I remember that I saw something like this for start-stop devices, but don't have any here for test... Can you please provide output from "gvfs-mount -li" for that device and also output from "gvfs-mount --monitor", which is printed when you press eject button for the one partition?
Created attachment 339470 [details] Output of "gvfs-mount -li"
Created attachment 339471 [details] Screenshot Note: all four of those volumes with an eject button reside on the same external hard disk.
root# gvfs-mount --monitor Monitoring events. Press Ctrl+C to quit. ... here I click on 50 GB's "eject" button ... Volume changed: '50 GB Volume' Mount changed: '50 GB Volume' Mount removed: '50 GB Volume' ... desktop notification: "You can now unplug 50GB Volume" ... ... and similarly for all the others ...
Thanks for looking at this issue :) This is a plain simple spinning HDD taken out from my old laptop that died a few days ago :D, put in an external case and connected via USB to my brand new computer (running a brand new Yakkety installation).
Thanks for the logs, thanks to them I found device with the same properties. This is a bug in GVfs, although I wonder why Nautilus sometimes unmount all of the partitions and sometimes only the one... Carlos, can you please point me to the relevant code in Nautilus?
Sure https://git.gnome.org/browse/gtk+/tree/gtk/gtkplacessidebar.c#n3032
Thanks, I see it already. Nautilus calls g_mount_eject if eject is supported, otherwise it calls g_mount_unmount. GVfs unmounts just the one mount, when g_mount_unmount is called. However, g_mount_eject invokes g_drive_eject, that's why all the mounts are unmounted sometimes... is there any result from the discussion with designers about the sidebar regarding to drives?
This unmount notification have been added by Bug 676111 long time ago. We should obviously set generic_text = TRUE in such case in order to print "%s has been unmounted\n" instead, see: https://git.gnome.org/browse/gvfs/tree/monitor/udisks2/gvfsudisks2utils.c#n818
Created attachment 339498 [details] [review] udisks2: Always use generic notification when unmounting "You can now unplug %s\n" is used for mounts with filesystem, "%s has been unmounted\n" is used otherwise. It is confusing to say "unplug" for drives with multiple mounts, or for drives, which need to be ejected, or stopped. I think "unplug" should be used only when ejecting, or stopping. It might lead to data loss if user unplug the device after unmounting one of several mounts. Actually, it makes sense to me to say "unplug" also if drive isn't ejectable, nor stopable and this is only one/last mounted volume, however, I don't think we want detect this case, because it seems to me fairly uncommon. I see this case only for my card reader, because all my flash drives are ejectable, and all my portable disks are stopable.
(In reply to Ondrej Holy from comment #9) > Thanks, I see it already. Nautilus calls g_mount_eject if eject is > supported, otherwise it calls g_mount_unmount. GVfs unmounts just the one > mount, when g_mount_unmount is called. However, g_mount_eject invokes > g_drive_eject, that's why all the mounts are unmounted sometimes... is there > any result from the discussion with designers about the sidebar regarding to > drives? I figured out that would be the problem too. I pinged Allan today but he didn't have time. I will try next week.
(In reply to Ondrej Holy from comment #11) > Created attachment 339498 [details] [review] [review] > udisks2: Always use generic notification when unmounting > > "You can now unplug %s\n" is used for mounts with filesystem, > "%s has been unmounted\n" is used otherwise. It is confusing > to say "unplug" for drives with multiple mounts, or for drives, > which need to be ejected, or stopped. I think "unplug" should > be used only when ejecting, or stopping. It might lead to data > loss if user unplug the device after unmounting one of several > mounts. > > Actually, it makes sense to me to say "unplug" also if drive > isn't ejectable, nor stopable and this is only one/last > mounted volume, however, I don't think we want detect this > case, because it seems to me fairly uncommon. I see this case > only for my card reader, because all my flash drives are > ejectable, and all my portable disks are stopable. why a drive would not be ejectable/stopped? Either the drive cannot be unpluged from the system and doesn't make sense to "eject" it or it can be, no?
I am not sure I understand what is your question. But see SAMSUNG HN-M750MBB drive in attachment 339470 [details]: can_eject=0, can_start=0, can_stop=0 (it is based on udisks2/udev). Only thing what you can do is unmount all the mounts, then you can unplug the device, although I am not sure it is safe, this is a question rather for udisks2/udev people...
That's another great point. The disk keeps spinning even after I unmount all partitions. I recall there being a command which halts the disk, after which it's obviously safe to remove it. I don't know if it's safe to remove it without halting first, but after the kernel has written everything it wanted to.
My question is, if it's not ejectable, why it says "you can unplug now" or we display any notification at all? If the disk/stick is supposed to be extracted, why has can_eject=0? That would be not our problem.
(In reply to Egmont Koblinger from comment #15) > That's another great point. The disk keeps spinning even after I unmount all > partitions. I recall there being a command which halts the disk, after which > it's obviously safe to remove it. I don't know if it's safe to remove it > without halting first, but after the kernel has written everything it wanted > to. It's not, but the drive should be ejectable if it's supposed to be ejectable. If not it's a udisk/kernel/firmware bug, not ours. Or I'm missing something obvious :)
(In reply to Carlos Soriano from comment #16) > My question is, if it's not ejectable, why it says "you can unplug now" or > we display any notification at all? You are right, it doesn't make sense either for this case. I will reword the commit message and push... > If the disk/stick is supposed to be extracted, why has can_eject=0? That > would be not our problem. That's problem lower in the stack (i.e. udisks/udev/kernel).
Created attachment 340223 [details] [review] udisks2: Always use generic notification when unmounting "You can now unplug %s\n" is used for mounts with filesystem, "%s has been unmounted\n" is used otherwise when unmounting. It is confusing to say "unplug" for drives with multiple mounts, or for drives, which need to be ejected, or stopped. I think "unplug" should be used only when ejecting, or stopping. It might lead to data loss if user unplug the device after unmounting one of several mounts.
Attachment 340223 [details] pushed as f760443 - udisks2: Always use generic notification when unmounting
Pushed also in gnome-3-22 branch...
Thanks Ondrej!